Skip to main content
Combine Restate and Pydantic Logfire to get full observability into your Pydantic AI agent executions. Logfire traces every LLM call, tool invocation, token usage, and cost. Restate traces every durable step, so you see agentic steps alongside regular workflow steps in a single trace. You don’t need to change your agent code. You only add the Logfire instrumentation to your entry point.

Logfire Documentation

Learn more about Logfire’s observability and Pydantic AI integration.

Instrumentation setup

Initialize Logfire and instrument Pydantic AI with RestateTracerProvider to correlate AI spans with Restate’s execution journal:
__main__.py
Prerequisites: Logfire account and token, OpenAI API key, Restate installed.Get the example:
Add your API keys to an .env file:
Start the agent service:
Start Restate:
Or the US equivalent tracing endpoint.Go to the Restate UI at http://localhost:9070, register the service at http://localhost:9080, click on the handler to go to the playground, and send the default request.

What you see in Logfire

Once you send a request, you can inspect the trace in Logfire. You see the agentic steps (LLM calls, tool invocations) alongside regular workflow steps (e.g. currency conversion, reimbursement), with inputs, outputs, model configuration, and token usage for each LLM call. Restate manages the execution, starts the parent span, and exports the full journal as OpenTelemetry traces. Pydantic AI attaches AI-specific spans and metadata under Restate’s parent span.
Logfire trace
Restate’s Tracer Provider flattens the Logfire spans to make them appear consistently structured with the Restate spans in the UI. We are working on a next iteration of the integration which will respect the Logfire span nesting and puts the Restate spans at the right depths inside them.