Skip to main content

Installation

Quick Start

What Gets Traced

The Pydantic AI integration automatically captures:
  • Agent runs — input prompt, output text (including structured Pydantic model output), model name
  • Token usage — input_tokens and output_tokens from the agent result
  • Finish reasonpydantic_ai.finish_reason captured from the last model response (e.g. "stop", "length", "tool_call")
  • Errors — error type and message captured in event properties, then re-raised to the caller
  • Async support — both run() (async) and run_sync() (sync) are instrumented
  • Double-wrap guard — calling wrap() twice on the same agent is a safe no-op

Configuration

Projects

Route events to a specific project by passing its slug as project_id:
project_id sets the X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. The same option is accepted by the create_raindrop_pydantic_ai(...) factory. Invalid slugs are ignored with a warning and no header is sent.

Multiple projects in one process

Available in raindrop-ai>=0.0.56. When one service runs several agents that should report to different projects, create one RaindropPydanticAI wrapper per project. Each wrapper owns its own raindrop.Raindrop client, so the two route independently — there is no shared module-level state:
Each wrapper owns its configuration and delivery pipeline, so agents handled by different wrappers route independently. To share a single client across wrappers (or with the module-level API), construct a raindrop.Raindrop yourself and pass it via client=:

Structured Output

The integration handles Pydantic AI’s structured output types — the output is serialized to JSON for telemetry:

Async Usage

The wrapper supports both sync and async agent runs:

Identifying Users

Use identify() to associate a user with traits:
Traits values must be str, int, bool, or float.

Tracking Signals

Use track_signal() to record feedback, edits, or custom signals:

Flushing and Shutdown

Always call flush() before your process exits to ensure all telemetry is shipped:

Factory Function (Legacy)

The create_raindrop_pydantic_ai() factory is available for backwards compatibility:

Known Limitations

  • run_stream() is not instrumented — only run() and run_sync() are captured. Streaming runs produce no telemetry.
  • Multi-step agent runs: In agents with multiple LLM calls (e.g., tool use loops), only the final result’s data is captured. Intermediate LLM calls are not tracked individually.