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.py

Configure remote gateway (optional)

export AGENTRUST_GATEWAY_URL=https://your-gateway.example.com
export AGENTRUST_KEY=at_team_your_key

Examples table

ExampleFrameworkPatternTierDoc
minimal.pyOpenAI + LangGraphAuto-instrumentOSSminimal.md
embedded_only.pyAnyembed + harnessOSSembedded-only.md
openai_direct.pyOpenAIA/B/C patternsOSSopenai-direct.md
langchain_agent.pyLangChainAuto-hook / harnessOSSlangchain-agent.md
langgraph_agent.pyLangGraphAgentTrustNodeTeamlanggraph-agent.md
crewai_agent.pyCrewAICallbackTeamcrewai-agent.md
autogen_agent.pyAutoGenReply hookTeamautogen-agent.md
multi_agent_chain.pyAnyTrust chainEnterprisemulti-agent-chain.md
fastapi_agent.pyFastAPILifespan + harnessOSSfastapi-agent.md
django_middleware.pyDjangoWSGI middlewareOSS
n8n_webhook.pyn8nHTTP webhookOSS

Integration patterns

PatternDescription
Aauto_instrument() — zero code change
B@harness decorator
CAgentTrustClient.validate()
DQueue mode + drain_queue()

Best Practices

  • Start with embedded_only.py or minimal.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.