Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://respan.ai/docs/mcp"
    }
  }
}
This integration is for the Respan gateway.

What is Pydantic AI?

Pydantic AI is a Python agent framework from the creators of Pydantic. Route LLM calls through the Respan gateway to access 250+ models with a single API key — no separate provider key needed.

Quickstart

Step 1: Install packages

pip install pydantic-ai

Step 2: Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

Step 3: Point the provider to the Respan gateway

Pydantic AI uses provider prefixes (e.g. openai:, anthropic:) to select the model. Set the provider’s base URL and API key to your Respan credentials:
import os

os.environ["OPENAI_BASE_URL"] = "https://api.respan.ai/api"
os.environ["OPENAI_API_KEY"] = os.environ["RESPAN_API_KEY"]

from pydantic_ai import Agent

agent = Agent(
    model="openai:gpt-4o",
    system_prompt="You are a helpful assistant.",
)
result = agent.run_sync("Tell me a joke")
print(result.output)

Step 4: Verify

Open the Logs page to see your gateway requests.
gateway
Looking for tracing integration? See Tracing > Pydantic.