paybondpaybond
Sign in

Python example projects

Runnable Python examples for Paybond Kit — agent middleware and framework adapters with TypeScript parity where available.

Paybond ships runnable Python examples under examples/ in the repository. Use them as reference implementations when you want a complete application structure beyond the Python quickstart.

Each example installs paybond-kit from the local monorepo (editable or path dependency) so SDK and example changes can be tested together. External apps should install the published wheel with pip install paybond-kit instead.

Example catalog

ExamplePathWhat it demonstrates
Agent-agnostic middlewareexamples/paybond-kit-runtime-agent-python/create_paybond_generic_agent_config with registry, bind, and auto-evidence
LangGraphexamples/paybond-kit-langgraph-python/run_langgraph_sandbox_demo and paybond_awrap_tool_call on the ToolNode boundary
Claude Agent SDKexamples/paybond-kit-claude-agents-python/create_paybond_claude_agents_config for in-process MCP tools
OpenAI Agents SDKSmoke via CLIcreate_paybond_openai_agents_config — use paybond agent demo openai-agents smoke (requires paybond-kit[openai-agents])
CrewAISmoke via CLIcreate_paybond_crewai_config on @tool / BaseTool — use paybond agent demo crewai smoke (requires paybond-kit[crewai])
Pydantic AISmoke via CLIcreate_paybond_pydantic_ai_config on Tool / callables — use paybond agent demo pydantic-ai smoke (requires paybond-kit[pydantic-ai])
Google ADKSmoke via CLIcreate_paybond_google_adk_config on FunctionTool — use paybond agent demo google-adk smoke (requires paybond-kit[google-adk])
Microsoft Agent FrameworkSmoke via CLIcreate_paybond_microsoft_agent_framework_config and function middleware — use paybond agent demo microsoft-agent-framework smoke (requires paybond-kit[microsoft-agent-framework])

Choose an example

Adding spend controls to an agent? Pick the row that matches your runtime:

TypeScript-only frameworks: Vercel AI SDK, Mastra, and Cloudflare Agents adapters are TypeScript-only today. Use the agent-agnostic path in Python, or see TypeScript example projects for those runtimes.

CLI smoke commands

Each example has a matching CLI smoke check. Pass --runtime python for Python kit execution:

paybond login   # optional for sandbox; required for real API

# Agent-agnostic
paybond agent demo generic smoke \
  --runtime python \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# LangGraph
pip install "paybond-kit[langgraph]"
paybond agent demo langgraph smoke \
  --runtime python \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Claude Agents
paybond agent demo claude-agents smoke \
  --runtime python \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# OpenAI Agents (requires paybond-kit[openai-agents])
pip install "paybond-kit[openai-agents]"
paybond agent demo openai-agents smoke \
  --runtime python \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# CrewAI (requires paybond-kit[crewai])
pip install "paybond-kit[crewai]"
paybond agent demo crewai smoke \
  --operation procurement.submit_po \
  --requested-spend-cents 12000 \
  --evidence-preset cost_and_completion \
  --format json

# Pydantic AI (requires paybond-kit[pydantic-ai])
pip install "paybond-kit[pydantic-ai]"
paybond agent demo pydantic-ai smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Google ADK (requires paybond-kit[google-adk])
pip install "paybond-kit[google-adk]"
paybond agent demo google-adk smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Microsoft Agent Framework (requires paybond-kit[microsoft-agent-framework])
pip install "paybond-kit[microsoft-agent-framework]"
paybond agent demo microsoft-agent-framework smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# MCP (in-process tool surface; requires paybond-kit[mcp])
pip install "paybond-kit[mcp]"
paybond agent demo mcp smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

For the fastest local path without an API key, use paybond dev loop --offline — see Agent quickstart.

Cloneable starter templates

Use standalone templates under templates/ or scaffold with either CLI:

paybond init --template invoice-agent
paybond init --template travel-agent --force

The Python-native starter is paybond-invoice-agent (LangGraph and saas preset). Other templates are TypeScript-first but copy cleanly from Python kit as well.

Running from a source checkout

Each example directory includes a README with setup steps. The usual pattern:

cd examples/<example-name>
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.py

Middleware examples typically need PAYBOND_API_KEY from paybond login or PAYBOND_API_KEY=pb_test_sandbox with a mock Gateway.

Optional extras for framework adapters:

pip install "paybond-kit[langgraph]"   # LangGraph hooks and agent demo langgraph smoke
pip install "paybond-kit[claude-agents]"  # Claude Agents SDK and agent demo claude-agents smoke
pip install "paybond-kit[openai-agents]"   # OpenAI Agents SDK and agent demo openai-agents smoke
pip install "paybond-kit[crewai]"         # CrewAI guards and agent demo crewai smoke
pip install "paybond-kit[pydantic-ai]"    # Pydantic AI guards and agent demo pydantic-ai smoke
pip install "paybond-kit[google-adk]"     # Google ADK guards and agent demo google-adk smoke
pip install "paybond-kit[microsoft-agent-framework]"  # MAF middleware and agent demo microsoft-agent-framework smoke
pip install "paybond-kit[mcp]"         # stdio MCP server (paybond-mcp-server)

For pipx: quote extras on zsh ('paybond-kit[langgraph]'); use pipx install 'paybond-kit[langgraph]' or pipx inject paybond-kit langgraph langchain-core if base paybond-kit is already installed; one-shot runs need pipx run --spec 'paybond-kit[langgraph]' paybond … (the CLI is paybond, not paybond-kit). See Python quickstart — pipx.

Partner dry run (Python)

examples/partner-dry-run-wiremock/ is a WireMock and Testcontainers harness for local Gateway and Signal contract testing. It is not an agent middleware demo — use it when validating HTTP integration contracts without a live Paybond stack. See the example README for Docker Compose and Testcontainers entry points.

What these examples are for

  • Understanding paybond-kit in a complete end-to-end agent middleware flow.
  • Seeing Python parity with the TypeScript adapter docs for LangGraph, Claude Agents, OpenAI Agents, and CrewAI.
  • Copying proven patterns for sandbox bootstrap, tool wrapping, and auto-evidence.
  • Validating a framework adapter in CI with the matching paybond agent demo … smoke --runtime python command.

For most teams, follow the Python quickstart or Agent quickstart first, then open the example that matches your stack.