TypeScript client

In this section10xgraph-client is the typed TypeScript SDK for a 10xGraph server in browser and Node.js: invoke, HTTP and WebSocket streaming, threads, memory and realtime.

  • 12 pages
  • About 72 min to read all

10xgraph-client is the typed TypeScript client for a running 10xGraph API server, for browser and Node.js apps. It covers invoke, streaming over HTTP and WebSocket, realtime audio, threads, memory, files, background tasks and client-side tools.

The server checks identity, thread ownership and rate limits on every request, so the part left to your frontend is to carry credentials without leaking them. Read Secure your frontend before you ship, and see Production readiness for what the server enforces.

What you need

Install Node 20 or later and the package:

Terminal
npm install 10xgraph-client

On Node 20, wsStream() and realtime() also need the ws package; see Create the client.

Transport modes

Method Transport Returns Use it for
invoke() HTTP POST The final result Background calls, simple chat
stream() HTTP, NDJSON body Chunks as they arrive Chat UIs that show tokens
wsStream() WebSocket The same chunks as stream() Graphs that call client-side tools often
realtime() WebSocket, binary audio A RealtimeSession Voice conversations with a live agent

With a thread_id, the server loads the thread’s history, so you send only the new message.

Core concepts

Threads: Omit thread_id to start a thread. The server picks the id and returns it in result.thread_id (or on each stream chunk). Pass it back to maintain a conversation across multiple API calls. The checkpointer on the server persists the full agent state, so each new request picks up where the last one stopped.

Remote tools: Tool schemas live on the server (in 10xgraph.json), but implementation runs in your client. This lets you call browser APIs (clipboard, geolocation), keep secrets local, or run integrations the server cannot access.

Pages in this section

Basics

Features

Frameworks

  • Next.js and React: Route handler proxy (keep tokens server-side), streaming React components, abort patterns

All pages in TypeScript client

Basics

  1. Secure your frontendHow a browser app talks to a production 10xGraph server without a secret: server-side proxy or short-lived user tokens, WebSocket auth, tools, error codes.5 min
  2. Create and configure the clientInstall 10xgraph-client and create a TenxGraphClient with bearer, Basic or custom-header auth, set a timeout and debug logging, and verify the connection.4 min
  3. Invoke the agentCall client.invoke() to send messages to your agent and get back responses with full control over threading, error handling, and response structure.4 min
  4. Stream responsesProcess agent output as it arrives with client.stream() and client.wsStream(): iterate StreamChunk events with for await, handling message, state and error.6 min
  5. Manage threadsList, filter by name, paginate, inspect, update and delete conversation threads and their messages with TenxGraphClient, backed by your graph's checkpointer.5 min

Features

  1. Remote toolsRun agent tools in the browser: declare remote_tools schemas in 10xgraph.json, register handlers in the TypeScript client for geolocation or clipboard.4 min
  2. Work with files and multimodal messagesUpload images, documents and audio with uploadFile() in the TypeScript client, check limits with getMultimodalConfig(), and reference files by file_id.6 min
  3. Use the memory APIStore, search, update and delete long-term memories with the TypeScript client, using storeMemory() and similarity search with a score threshold for context.5 min
  4. Graph utilities and human-in-the-loopInspect graph topology and state, stop execution, repair broken threads, view execution traces, and handle interrupts for human approval workflows.10 min
  5. Build a realtime audio conversationStream microphone audio to a LiveAgent with client.realtime(): capture PCM16 at 16 kHz, play the agent's PCM16 reply in the browser, and match the audio rates.10 min
  6. Error handlingCatch TenxGraphError subclasses from the TypeScript client, log them with toJSON(), and retry transient failures such as timeouts, 502/504 and 429 rate limits.5 min

Frameworks

  1. Call 10xGraph from Next.js and ReactIntegrate a 10xGraph Python agent backend with Next.js using route handlers for secure streaming and Server Actions for non-streaming calls.8 min