Raindrop integration for Pydantic AI — automatic observability for Agent run() and run_sync() calls
Project description
raindrop-pydantic-ai
Raindrop integration for Pydantic AI. Automatically captures Agent run() and run_sync() calls including input, output, model name, token usage, and finish reason.
Installation
pip install raindrop-pydantic-ai pydantic-ai
Quick Start
from raindrop_pydantic_ai import RaindropPydanticAI
from pydantic_ai import Agent
raindrop = RaindropPydanticAI(
api_key="your-write-key",
user_id="user-123",
)
agent = Agent("openai:gpt-4o", system_prompt="Be helpful")
raindrop.wrap(agent)
result = agent.run_sync("What is the capital of France?")
print(result.output)
raindrop.flush()
Async Usage
import asyncio
from raindrop_pydantic_ai import RaindropPydanticAI
from pydantic_ai import Agent
raindrop = RaindropPydanticAI(api_key="rk_...", user_id="user-123")
agent = Agent("openai:gpt-4o")
raindrop.wrap(agent)
async def main():
result = await agent.run("What is the capital of France?")
print(result.output)
raindrop.flush()
asyncio.run(main())
Factory Function (Legacy)
The create_raindrop_pydantic_ai() factory function is still available for backwards compatibility:
from raindrop_pydantic_ai import create_raindrop_pydantic_ai
raindrop = create_raindrop_pydantic_ai(api_key="rk_...", user_id="user-123")
What Gets Captured
- Agent runs: input prompt, output text (including structured output), model name
- Token usage:
input_tokensandoutput_tokensfrom the result - Finish reason:
pydantic_ai.finish_reasoncaptured from the last model response (e.g."stop","length","tool_call") - Errors: error type and message captured in event properties, then re-raised
- Async support: both
run()(async) andrun_sync()(sync) are instrumented - Double-wrap guard: calling
wrap()twice on the same agent is a safe no-op
API Reference
RaindropPydanticAI(api_key, user_id=None, convo_id=None, tracing_enabled=True, bypass_otel_for_tools=True, debug=False)
Create a new Raindrop wrapper instance.
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | None |
None |
Raindrop API key. When None or empty, telemetry is disabled |
user_id |
str | None |
None |
Associate all events with a user |
convo_id |
str | None |
None |
Group events into a conversation |
tracing_enabled |
bool |
True |
Enable/disable tracing in raindrop.init() |
bypass_otel_for_tools |
bool |
True |
Bypass OpenTelemetry for tool calls |
debug |
bool |
False |
Enable DEBUG-level logging for the package |
Debug Mode
raindrop = RaindropPydanticAI(
api_key="rk_...",
debug=True, # enables DEBUG-level logging
)
identify(user_id, traits=None)
Identify a user with optional traits:
raindrop.identify("user-123", traits={"name": "Alice", "plan": "pro", "age": 30})
track_signal(event_id, name, signal_type="default", ...)
Track a signal event (feedback, edits, etc.):
raindrop.track_signal(
event_id="evt-abc",
name="thumbs_up",
signal_type="feedback",
sentiment="POSITIVE",
comment="Great answer!",
)
flush() / shutdown()
Flush pending events before your process exits:
raindrop.flush() # flush pending data
raindrop.shutdown() # flush + release resources
Methods
| Method | Description |
|---|---|
wrap(agent) |
Instrument a Pydantic AI Agent |
flush() |
Flush pending events to Raindrop |
shutdown() |
Flush and shut down the client |
identify(user_id, traits=None) |
Identify a user with optional traits |
track_signal(event_id, name, signal_type="default", ...) |
Track a custom signal event |
Testing
cd packages/pydantic-ai-python
pip install -e ".[dev]"
python -m pytest tests/ -v
Full Documentation
See Raindrop Pydantic AI Integration Docs for full documentation.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raindrop_pydantic_ai-0.0.3.tar.gz.
File metadata
- Download URL: raindrop_pydantic_ai-0.0.3.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24f845d562c19ccb258e57cdc93aabbed5bdfd7035f7e270b7f667137070a528
|
|
| MD5 |
d1679b1357a06e756c8e75f8b658b3c7
|
|
| BLAKE2b-256 |
9ee90caa57dab790b84ce592d7e4324cb34eb0b4a2cc9b5dbd509b22f7642856
|
File details
Details for the file raindrop_pydantic_ai-0.0.3-py3-none-any.whl.
File metadata
- Download URL: raindrop_pydantic_ai-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2055b5815c34e83e9433b67be32ed757d907b778b11b3145f0d7b82deab62e8
|
|
| MD5 |
14c74bb9b2da37f537676b81d61c3a69
|
|
| BLAKE2b-256 |
2d570cb3f773fa5e52c42b3108014b4c467e00a49b896d372305102fddcf3595
|