Set up Respan
Set up Respan
- Sign up — Create an account at platform.respan.ai
- Create an API key — Generate one on the API keys page
- Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Use AI
Use AI
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
What is Pydantic AI?
Pydantic AI is a Python agent framework from the creators of Pydantic. It provides a type-safe way to build AI agents with tool use, structured outputs, and multi-model support. The Respan integration usesrespan-exporter-pydantic-ai to capture traces, spans, and metrics from agent runs via OpenTelemetry.
Example projects
Example projects
Setup
Install packages
respan-exporter-pydantic-ai automatically installs respan-tracing.Set environment variables
RESPAN_API_KEY is used for trace export. OPENAI_API_KEY is used by Pydantic AI to call the LLM directly.Using the Respan gateway instead?
Using the Respan gateway instead?
You can skip Set the provider’s base URL and key to your Respan credentials:See the full gateway guide for more details.
OPENAI_API_KEY by routing calls through the Respan gateway. The gateway uses your RESPAN_API_KEY for both the LLM call and trace export.View your trace
Open the Traces page to see your agent trace.

Configuration
RespanTelemetry options
| Parameter | Type | Default | Description |
|---|---|---|---|
app_name | str | — | Application name shown in Respan. |
api_key | str | RESPAN_API_KEY env var | Respan API key. Optional if env var is set. |
base_url | str | RESPAN_BASE_URL env var | Respan base URL. Optional if env var is set. |
is_enabled | bool | True | Set to False to disable tracing. |
is_batching_enabled | bool | True | Batch export; set False for immediate flush in tests. |
instrument_pydantic_ai() options
| Parameter | Type | Default | Description |
|---|---|---|---|
agent | Agent | None | None | Instrument a single agent. If None, all agents are instrumented globally. |
include_content | bool | True | Include message content in telemetry. |
include_binary_content | bool | True | Include binary content in telemetry. |
Attributes
Attach Respan attributes to the current span usingget_client().update_current_span():
| Attribute | Type | Description |
|---|---|---|
customer_identifier | str | Identifies the end user in Respan. |
metadata | dict | Arbitrary key-value metadata attached to the span. |
custom_tags | list[str] | Tags for filtering and grouping in the dashboard. |

Examples
Workflows and tasks
Use@workflow and @task decorators from respan-tracing to group spans into logical workflows and tasks.

Tool calls
Agents that use tools are traced automatically — tool calls and results appear as spans.
Looking for gateway integration? See Gateway > Pydantic.