Examples
Examples
Cookbook of framework integration examples for AgentTrust.
Examples
Overview
Runnable cookbooks in the examples/ directory demonstrating every major integration pattern and framework. Each example is self-contained.
Why It Matters
Learning by example is the fastest path to production integration. Start with the example closest to your stack.
Prerequisites
pip install "agentrust-sdk[embedded,retry]"Step-by-Step Guide
Run any example
cd examples/
python minimal.pyConfigure remote gateway (optional)
export AGENTRUST_GATEWAY_URL=https://your-gateway.example.com
export AGENTRUST_KEY=at_team_your_keyExamples table
| Example | Framework | Pattern | Tier | Doc |
|---|---|---|---|---|
minimal.py | OpenAI + LangGraph | Auto-instrument | OSS | minimal.md |
embedded_only.py | Any | embed + harness | OSS | embedded-only.md |
openai_direct.py | OpenAI | A/B/C patterns | OSS | openai-direct.md |
langchain_agent.py | LangChain | Auto-hook / harness | OSS | langchain-agent.md |
langgraph_agent.py | LangGraph | AgentTrustNode | Team | langgraph-agent.md |
crewai_agent.py | CrewAI | Callback | Team | crewai-agent.md |
autogen_agent.py | AutoGen | Reply hook | Team | autogen-agent.md |
multi_agent_chain.py | Any | Trust chain | Enterprise | multi-agent-chain.md |
fastapi_agent.py | FastAPI | Lifespan + harness | OSS | fastapi-agent.md |
django_middleware.py | Django | WSGI middleware | OSS | — |
n8n_webhook.py | n8n | HTTP webhook | OSS | — |
Integration patterns
| Pattern | Description |
|---|---|
| A | auto_instrument() — zero code change |
| B | @harness decorator |
| C | AgentTrustClient.validate() |
| D | Queue mode + drain_queue() |
Best Practices
- Start with
embedded_only.pyorminimal.py - Copy the pattern closest to your framework
- Promote to remote gateway by changing env vars only
Common Mistakes
- Running LangGraph/CrewAI examples without Team API key
- Missing framework-specific pip packages
Troubleshooting
See individual example docs and Troubleshooting.