Examples
In this sectionRunnable Python AI agent examples for 10xGraph with full source code: tools, streaming, MCP, memory, RAG, multi-agent, production features and full-stack apps.
- 38 pages
- About 335 min to read all
Every page in this section is a runnable example from the 10xGraph repository. Each page explains what the example builds, walks through the code file by file, and ends with the full source of every file in tabs, so you can read it here or copy it straight into your project.
The code in the repository is the source of truth. If an example on this page does not run or differs from the repository, please open a pull request: use Edit this page on GitHub at the bottom of the page, or Report an issue if you are not sure.
Run any example
git clone https://github.com/10xGraph/10xGraph.git
cd 10xGraph/agentflow
pip install "10xgraph[openai,google-genai,anthropic]"
cp examples/.env.example .env # add the API key for the provider the example uses
python examples/quickstart/quickstart.pyEach page lists the extras and the one environment variable its example needs. The model string is written in each file, so changing provider is a one-line edit.
Getting started
Tools and integrations
Production
Memory and patterns
Multimodal and quality
Deployment
Use cases
Full-stack apps
All pages in Examples
Production
- Serve an agent with auth, from init to DockerScaffold the Full setup with 10xgraph init, run it with JWT auth, call it with curl and TenxGraphClient, then generate Docker files with 10xgraph build.4 min
- A payment tool that cannot charge twiceA charge_card tool that asks for approval with interrupt(), sends an idempotency key and uses the checkpointer ledger, so a resumed run never charges twice.4 min
- Human approval over the APIPause a refund agent with interrupt() and a response_schema, read the open request from the API, resume with resume and interrupt_id, and handle 409 and 422.4 min
- Two users, one server, no shared threadsServe one agent to two users with JWT auth and ownership, then see what each user can and cannot reach. The statuses shown were captured from a running server.4 min
- File and web tools that stay in boundsGive a support agent a read-only knowledge base with create_file_tools, a host-restricted fetch_url wrapper, and a MediaFetchPolicy for image URLs.4 min
- Security regression tests for an agentCatch a prompt-injected agent in CI. An eval set that expects zero tool calls, plus a pytest check that no tool outside the allow-list was requested.4 min
- Graceful Shutdown for a Python AI Agent Service with 10xGraphHandle SIGINT and SIGTERM in a long-running 10xGraph agent service, flush checkpoint writes, and release resources with graph.aclose() and async with.7 min
- Retries, Fallback Models and Circuit Breaker for a Python AI Agent in 10xGraphMake a 10xGraph agent survive provider outages with RetryConfig backoff, a circuit breaker, cross-company fallback models, and a recursion limit.7 min
- Human-in-the-Loop Approval with interrupt() in a Python AI Agent (10xGraph)Pause a 10xGraph ReactAgent for human approval with interrupt() and a JSON schema or interrupt_before, then resume the same thread in Python.7 min
- Persist Agent Conversations with SQLite, PostgreSQL and Redis Checkpointers in 10xGraphSave and resume a Python AI agent conversation by thread_id with 10xGraph's InMemory, SQLite and PostgreSQL plus Redis checkpointers, and read state back.9 min
- Context Window Management for Python AI Agents - Trim and Summarize with 10xGraphKeep long agent conversations inside the token limit in 10xGraph with MessageContextManager trimming and SummaryContextManager summaries from a cheaper model.6 min
- Callbacks, Validators and Lifecycle Hooks in 10xGraphAdd logging, timing, cost tracking, prompt injection validation, lifecycle hooks and secret redaction to a 10xGraph Python AI agent with CallbackManager.10 min
- Observability and Event Publishers for 10xGraph AgentsStream 10xGraph run events to the console, OpenTelemetry, Logfire, LangSmith, Redis, Kafka or RabbitMQ and combine several publishers in Python.10 min
- Serve a 10xGraph Agent as a REST and SSE APIDeploy a 10xGraph Python AI agent with the 10xgraph-api server. Configure 10xgraph.json, call /v1/graph/invoke and /v1/graph/stream, use the TypeScript client.5 min
Getting started
- 10xGraph Quickstart - Your First Python AI Agent with ToolsBuild a Python AI agent with 10xGraph in about 30 lines: a ReactAgent with one tool, run with ainvoke or invoke, a thread_id and clean shutdown.4 min
- 10xGraph StateGraph Basics - Custom State, Routing and CommandLearn the 10xGraph StateGraph in Python with no API key: custom AgentState fields, function nodes, conditional edges and Command, plus a hand-built ReAct agent.6 min
- Streaming a 10xGraph Python AI Agent with astream and StreamEmitterStream agent output in 10xGraph with astream: read StreamChunk events, print text as it arrives, report tool progress with StreamEmitter, stop with astop.5 min
Tools and integrations
- Tools in 10xGraph - @tool Decorator, Injected Params, ToolResult and Remote ToolsDefine Python agent tools in 10xGraph: the @tool decorator with tags, injected state and config, ToolResult state updates, prebuilt tools and client-side tools.10 min
- LLM Providers in 10xGraph - OpenAI, Gemini, Claude, DeepSeek, OllamaRun one 10xGraph ReactAgent on OpenAI, Google Gemini and Vertex AI, Anthropic Claude (direct, Vertex, Bedrock), DeepSeek and Ollama by changing the model.8 min
- Dependency Injection in 10xGraph Agents with InjectQRegister your own services in an InjectQ container, receive them in 10xGraph tools and nodes with Inject[T], and swap them in tests with override_node.6 min
- MCP Tools in a Python AI Agent with 10xGraphConnect a 10xGraph ReactAgent to local and remote MCP servers over streamable HTTP, use several servers at once, and send auth headers in Python.6 min
- GitHub MCP Server with a 10xGraph AgentUse GitHub's remote MCP server from a 10xGraph ReactAgent to list commits and download a README, authenticated with a GitHub token in Python.4 min
- Xquik MCP Server with a 10xGraph AgentConnect a 10xGraph ToolNode or ReactAgent to the remote Xquik MCP server with fastmcp, an x-api-key header and streamable-http, then list its tools in Python.3 min
Memory and patterns
- Long-Term Agent Memory with Postgres and Qdrant in 10xGraphGive a 10xGraph Python agent long-term memory across sessions with MemoryConfig, PgVectorStore in Postgres or local Qdrant, user memory and shared agent memory.12 min
- RAG Agent with Qdrant and Reranking in 10xGraph (Python)Build a retrieval-augmented generation agent in Python with 10xGraph RAGAgent, a local Qdrant store, Gemini embeddings and optional reranking.5 min
- Structured Output with Pydantic in 10xGraph AgentsGet typed Pydantic output from a 10xGraph Python AI agent with output_schema, or use StructuredOutputAgent to validate replies and retry with repair prompts.5 min
- Multi-Agent Patterns in Python with 10xGraphBuild supervisor, swarm, manual handoff and plan-act-reflect multi-agent systems in 10xGraph where each agent runs on a different company's LLM.12 min
- Agent Skills in 10xGraph - On-Demand and Per-Tenant Session ModeLoad SKILL.md instructions into a 10xGraph Python agent on demand with activate_skill, or preload a per-tenant persona with session mode and bundled resources.10 min
Multimodal and quality
- Multimodal Agents in 10xGraph - Image, Document, Audio and Video InputSend images, PDFs, audio and video to a 10xGraph Python agent by URL, base64 or media-store reference, with MultimodalConfig and MediaFetchPolicy.8 min
- Realtime Voice Agent with Gemini Live in 10xGraph (Python)Build a realtime audio-to-audio voice agent with 10xGraph AudioAgent and Gemini Live. Stream a WAV file or microphone, call tools by voice, or use a WebSocket.11 min
- Test 10xGraph Agents Without an LLM Using pytestUnit test a 10xGraph Python AI agent offline with TestAgent, QuickTest, MockToolRegistry, MockMCPClient and override_node, with no API keys or network calls.9 min
- Evaluate a 10xGraph Agent with Trajectory and LLM Judge CriteriaEvaluate a 10xGraph Python agent with pytest. Score tool trajectories, run LLM-as-judge criteria and user simulation, write console, JSON, HTML reports.18 min
Use cases
- Customer Support Swarm with Human Approval and Memory in 10xGraphBuild a Python customer support agent swarm on Gemini, OpenAI and Claude with refund approval via interrupt(), SQLite persistence and Qdrant memory.21 min
- Research Assistant with Plan-Act-Reflect and a Structured Report in 10xGraphBuild a Python research agent that plans, searches, reflects and writes a Pydantic report, using Claude, GPT-5 mini, Gemini and DeepSeek in one 10xGraph.17 min
- Build a Data Extraction AI Agent in PythonBuild a data extraction agent in Python that turns unstructured text into validated Pydantic records and retries when validation fails, with 10xGraph.6 min
- Build a Coding AI Agent in PythonBuild a plan-first coding agent with read, search, test and diff-proposing tools, so every file change is reviewed by a human before it lands.8 min
Apps
- Docs Assistant with RAG, Qdrant and a React Chat UI (10xGraph)Build a full-stack RAG docs assistant: a Claude ReactAgent searching Qdrant, Postgres and Redis for threads, a React chat UI and Docker Compose.34 min
- CopilotKit Frontend for a 10xGraph Agent over AG-UIBuild a task board with a Next.js CopilotKit chat UI and a Python 10xGraph ReactAgent served over AG-UI, with shared state, approvals and Docker Compose.22 min