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:
npm install 10xgraph-clientOn 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
- Secure your frontend: Proxy or short-lived tokens, WebSocket auth, remote tool trust, and 401, 403, 409, 429
- Create and configure a client: Set auth tokens, timeout, proxy headers, and environment-specific URLs
- Invoke and get results: Call the agent and await the final response
- Stream responses: Consume token-by-token or message-by-message as they arrive
- Manage threads: List threads, fetch history, update state, delete old conversations
Features
- Run client-side tools: Register handlers; the client runs them during invoke and stream
- Send files and media: Upload images, audio, documents; send them in messages
- Use the memory API: Store and search long-term memory (semantic, metadata, facts)
- Graph utilities: Inspect the graph, stop and repair runs, answer pauses, read run traces
- Realtime audio: Voice-to-voice audio over the
/v1/graph/liveWebSocket bridge - Handle errors: Catch and retry transient failures, parse error details
Frameworks
- Next.js and React: Route handler proxy (keep tokens server-side), streaming React components, abort patterns
All pages in TypeScript client
Basics
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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