Skip to main content
Available for: Python agents (configured via a TypeScript helper).
Pydantic AI is a Python-only agent framework, but the helper for it lives in @zespan/sdk (TypeScript). There’s no Python-side zespan.integrations.pydantic_ai module and no wrapper function to call from your agent code — getPydanticAIConfig() is a one-off config generator, not a runtime integration.

How this integration works

Pydantic AI instruments itself with Logfire, which is OpenTelemetry-native. Instead of wrapping calls in your agent code, you point Logfire’s OTel exporter at Zespan’s ingest endpoint using environment variables. getPydanticAIConfig(otlpEndpoint) builds that exact set of environment variables for you from a single OTLP endpoint argument, so you don’t have to hand-write Logfire’s variable names yourself. Because it’s a config generator rather than something that runs inside your Python process, you typically call it once — from wherever you already provision the Python agent’s environment (a Node/TS setup script, an internal deploy tool, a Dockerfile build stage, a CI job) — and then apply the resulting values to that process.

Installation

Usage

Call getPydanticAIConfig() with the OTLP endpoint you want the agent to export to. It returns a plain Record<string, string> — it only builds the values, it does not set them in any environment for you.

What it generates

Applying the config to your Python process

getPydanticAIConfig() only produces the four values above — getting them into the environment the Python process reads from is a separate step. A few common ways to do that: Write a .env file the Python process loads on startup:
Pass them directly when spawning the Python process:
Or set them manually in whatever mechanism configures the Python environment — these four keys are the entire contract; nothing else needs to change in your Pydantic AI code:
Once those variables are set, Pydantic AI’s own Logfire integration picks them up automatically:
There’s no Python-side zespan package involved in this flow. Zespan’s role is limited to generating the right OTel/Logfire environment variables from the TypeScript SDK — everything else is standard Pydantic AI and Logfire instrumentation.