API server

In this sectionThe 10xGraph API server handles FastAPI endpoints for graph invocation, streaming, threading, memory, media, and observability with auth, rate limiting, and WebSocket.

  • 10 pages
  • About 92 min to read all

The 10xGraph API server is the production layer around your agent. It adds authentication and role-based access, per-user data isolation, durable thread state, rate limits, metrics, logs and deploy files, with no infrastructure code in your graph. This section is the single source of truth for operating the 10xGraph API server.

What the server does for you

Running your graph behind 10xgraph-api gives you these guarantees without code in your agent. Each row links to the page that explains it.

Guarantee What it means Details
Authentication JWT or your own BaseAuth on every route except /ping and /health/ready. You must configure it: auth: null is allowed, even in production. Authentication
Ownership isolation In production (and whenever auth is on) every query is filtered by the caller’s role reach (own by default, or tenant / all if you configure it). A thread outside the caller’s reach answers 404 before the model runs. Runs and state writes always stay on the caller’s own threads. Thread ownership
Scoped authorization Per-route scopes, and a boot-time route guard that refuses to start if any non-public route has no permission check. Authorization scopes
Input rules Request size limit, client messages limited to the user role, built-in state fields not writable, current_node and state values validated. Invoke and stream, CORS and security headers
Rate limits and run caps Sliding-window limits (counters in the cache store: memory or Redis) and a per-run timeout (300 s by default in production). Rate limiting
Production mode MODE=production validates itself at startup, turns off /docs, and hides 5xx error text. Production checklist
Durable state Threads, state and messages go through your checkpointer; with PgCheckpointer they survive restarts and are shared across replicas. Backup and restore, Kubernetes
Deploy files 10xgraph build writes a hardened Dockerfile and optional Compose and Kubernetes files. Deploy
Observability Metrics (off until you configure metrics), JSON logs with LOG_FORMAT=json, an optional audit log, Sentry and OpenTelemetry hooks, and per-thread run traces in development. Observability

For the reasoning behind these and the limits of what the server protects, read Production readiness, the security model and what 10xGraph does not protect.

What the server does

Running 10xgraph dev (add --no-open to skip the playground) starts a Uvicorn ASGI development server on port 8000 that exposes your compiled graph alongside infrastructure for real applications: stateful thread management, semantic memory, multimodal file handling, JWT or custom authentication, rate limiting, and structured logging and tracing. The server reads two inputs: your 10xgraph.json configuration file (which graph to load, which auth backend, storage layer) and environment variables for secrets and runtime tunables. Your graph logic stays in Python; the server handles the transport layer, persistence, and cross-cutting concerns.

The server is mode-aware: development mode (MODE=development, the default) leaves CORS open; production mode (MODE=production) refuses wildcard CORS with credentials, turns off the /docs and /redocs pages unless you set their paths, and defaults to ownership-based thread isolation. A single codebase switches between modes via environment variables, so your Docker image works in both dev and production.

API routes by function

The server organizes its endpoints into logical groups. Here is the complete route map:

Group Prefix Auth required What it does
Health /ping No Unauthenticated liveness check; returns 200 OK while the process is up. /health/ready (also unauthenticated) checks the backends and returns 200 or 503. Used by load balancers and orchestrators.
Graph /v1/graph/* Yes Invoke and stream the graph (invoke, stream), read its structure (GET /v1/graph, GET /v1/graph/tools), manage runs (stop, fix), and read the state schema (GET /v1/graph:StateSchema). Streaming returns NDJSON (one event per line).
Threads /v1/threads/* Yes Manage thread state and history: list threads, read and update thread state, add, list, update and delete messages, and delete threads. Requires a checkpointer; without one, threads are not persisted.
Tasks /v1/tasks/* Yes Start, schedule, read and cancel background tasks run by 10xgraph worker. Only on with a worker key in 10xgraph.json; see Background tasks.
Store /v1/store/* Yes Semantic memory CRUD and search: save memories, list and retrieve them, forget specific entries, and search across all stored memories. Requires a store backend; see Use memory store.
WebSocket /v1/graph/ws, /v1/graph/live Yes Two WebSocket endpoints for streaming: /ws for traditional streaming (events as JSON frames), /live for realtime audio and bidirectional messaging. Choose based on your transport needs.
AG-UI /v1/ag-ui Yes Run the graph over the AG-UI protocol for CopilotKit and other AG-UI-compatible clients. Off by default; enable with ag_ui.enabled: true in 10xgraph.json. Requires the ag-ui SDK extra.
Media/Files /v1/files/* Yes Upload, retrieve, and introspect multimodal files (images, audio, documents): POST /v1/files/upload, GET /v1/files/{id}, GET /v1/files/{id}/info, and GET /v1/files/{id}/url for signed URLs.
Config /v1/config/multimodal Yes Read the server’s multimodal configuration (supported MIME types, size limits, extraction settings).
Observability /v1/observability/{thread_id} Yes Retrieve a reconstructed run trace for a thread (spans, events, token usage). Development only: returns empty in MODE=production.

For detailed route signatures and response shapes, see the REST API reference.

Authentication and authorization

All endpoints except /ping and /health/ready enforce an auth + authorization layer. Your choice at configuration time determines what credentials are required:

  • No auth ("auth": null in 10xgraph.json): All authenticated endpoints allow any request. Safe for internal networks or local development behind a firewall.
  • JWT ("auth": "jwt"): Bearer token checked against a shared secret (JWT_SECRET_KEY). Standard, stateless, and suitable for mobile and SPAs.
  • Custom ("auth": {"method": "custom", "path": "module:attr"}): Your own BaseAuth subclass; route requests to any identity provider (LDAP, OAuth2, SAML, API key validation).

Authorization is part of the auth setting and applies to any auth class:

  • Owner-only data (default whenever auth is on): the default permission set and reach own. A user reaches only their own threads, memories and files, and another user’s thread answers 404.
  • Roles: add roles to the auth object to map token roles to resource:action permissions (such as graph:invoke or store:write) and a reach of own, tenant or all. Permissions guard routes, not individual tools; to check a permission inside a tool, use can(config, "store:write") from tenxgraph.core.authz.
  • Custom rules: override BaseAuth.authorize for rules the role table cannot express.

WebSocket and HTTP endpoints both enforce authentication via the Authorization: Bearer <token> header. WebSocket also accepts the token in the Sec-WebSocket-Protocol header as 10xgraph-bearer, <token> (the deprecated agentflow-bearer name still works). A ?token= query parameter is not accepted, so a token never lands in URLs or logs. HTTP routes read only the Authorization header. See Secure your server for setup and examples.

Development vs. production modes

The MODE environment variable switches the server’s security and logging posture:

  • MODE=development (default): Unauthenticated /ping and /health/ready accessible, ORIGINS="*" (CORS allows any domain), debug mode is on. Use for local development and testing.
  • MODE=production: Only /ping and /health/ready are unauthenticated, a graph run is cancelled after 300 seconds unless you change runs.timeout, wildcard CORS with credentials is refused (set ORIGINS explicitly), and /docs and /redocs are disabled unless you set DOCS_PATH and REDOCS_PATH. debug mode is off, and graph introspection needs the graph:read permission. Security headers (HSTS, X-Frame-Options and others) are on in every mode unless SECURITY_HEADERS_ENABLED=false. Use for deployments exposed to the internet.

Together with JWT_SECRET_KEY (a strong, randomly generated secret in production) and an explicit ORIGINS list, production mode refuses to start with wildcard CORS and credentials enabled. STRICT_PRODUCTION_CHECKS is on by default in production and also refuses a wildcard ORIGINS, a wildcard ALLOWED_HOST and enabled docs paths, so set ORIGINS and ALLOWED_HOST to your real values. Set STRICT_PRODUCTION_CHECKS=false to opt out.

MODE accepts production or prod, and development, dev or local, in any case. Unset means development. Any other value stops the server at startup, and 10xgraph dev exits with code 2.

Reading order for this section

This section is organized by task and layer:

Basics (how to run and configure):

  1. Run the server: start the server in dev and production, set the port, enable hot-reload
  2. Configure: write your 10xgraph.json file with your graph path, auth, store, and rate limiting (the checkpointer goes to compile() in your graph code)
  3. Project setup: use 10xgraph init to scaffold a project with templates
  4. CLI reference: overview of all 10xgraph commands

Security (auth, rate limits, headers):

  1. Authentication and authorization: set up JWT or custom auth, define who can access what
  2. Rate limiting: prevent abuse and manage resource usage
  3. CORS and security headers: restrict domains, set strict headers, trust proxies

Interfaces (how to call the server):

  1. Invoke and stream: make REST calls with curl and code; invoke for single requests, stream for real-time event responses
  2. WebSocket: use ws:// and wss:// for streaming and realtime audio; when to choose /ws vs /live
  3. AG-UI: integrate with CopilotKit and other AG-UI frameworks
  4. Files and multimodal: upload and manage images, audio, and documents
  5. Remote tools: let clients define tools that run on the server

Operations (deploy, monitor, maintain):

  1. Observability: enable logging, metrics, and tracing; forward traces to Logfire or Sentry
  2. Deploy: generate Docker images with 10xgraph build; deploy to Docker Compose, Kubernetes, or reverse-proxy setups
  3. Kubernetes: production checklist for Kubernetes deployments
  4. Production checklist: hardening steps before you go live (secrets, CORS, auth, persistence, rate limits)
  5. Backup and restore: back up thread state and restore from backups

Tools (playground and debugging):

  1. Playground: test your graph interactively with the web UI

If you are new to 10xGraph, start with Basics. If you are running in production or planning to, read Security and Operations top-to-bottom. If you are integrating 10xGraph into an existing app, the Interfaces pages show you how to make requests from your code.

All pages in API server

Basics

  1. Run the API ServerStart the 10xGraph development server with 10xgraph dev, and run it in production with the Gunicorn image from 10xgraph build.6 min
  2. Configure 10xgraph.jsonTask guide for setting the common 10xgraph.json keys, wiring a checkpointer, store and auth, and keeping separate configs per environment.14 min
  3. Initialize a ProjectScaffold a 10xGraph project with interactive prompts or CLI flags, and understand what each setup generates.7 min
  4. CLI OverviewQuick reference for 10xGraph CLI commands: scaffold, serve, test, and deploy agents.7 min

Interfaces

  1. Invoke and stream over RESTCall your graph over HTTP: synchronous invoke, streaming with NDJSON, thread management, stop and fix operations.12 min
  2. WebSocket streaming and realtimeBidirectional WebSocket endpoints for turn-based agent streaming and realtime audio.12 min
  3. Serve your agent over AG-UIEnable AG-UI support in 10xGraph to connect chat frontends like CopilotKit, test the endpoint, configure for production.5 min
  4. Handle files and multimodal inputEnable clients to upload images, audio, and documents to your agent via the file API.13 min
  5. Remote toolsConfigure client-executed tools on the server: define them in 10xgraph.json, attach them to graph nodes, and let clients run them.7 min

Tools

  1. PlaygroundTest your agent with the 10xGraph playground, a hosted UI for interactive development and debugging.9 min