Pydantic AI (gateway)

Route OpenAI-compatible Pydantic AI model calls through the Respan gateway to use 250+ models from different providers. Only your RESPAN_API_KEY is needed — no separate provider keys required.

Setup

1

Install packages

$pip install pydantic-ai
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No OPENAI_API_KEY needed — the Respan gateway handles provider authentication.

3

Point Pydantic AI to the Respan gateway

Python
1import os
2
3respan_api_key = os.environ["RESPAN_API_KEY"]
4respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
5
6os.environ["OPENAI_API_KEY"] = respan_api_key
7os.environ["OPENAI_BASE_URL"] = respan_base_url
8
9from pydantic_ai import Agent
10
11agent = Agent(
12 model="openai-chat:gpt-5.5",
13 system_prompt="You are a helpful assistant.",
14)
15
16result = agent.run_sync("What is the capital of France?")
17print(result.output)

Switch models

Change the model string to another OpenAI model ID through the same gateway-backed provider configuration.

1agent = Agent(
2 model="openai-chat:gpt-5.5",
3 system_prompt="You are a helpful assistant.",
4)

Pydantic AI’s openai-chat: prefix is a provider namespace that keeps this setup on Chat Completions. This page avoids showing Claude or Gemini behind that prefix; use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.

See the full model list.