Kitaru PydanticAI adapter
Record and replay PydanticAI agent runs with Kitaru.
Install
uv add "kitaru-pydantic-ai[openai]"
Install kitaru-pydantic-ai without the extra when your project provides another PydanticAI model implementation.
Use
import uuid
from pydantic_ai import Agent
from kitaru_pydantic_ai import KitaruAgent
agent = KitaruAgent(
Agent("openai:gpt-5-nano"),
agent_id=uuid.UUID("018f0000-0000-7000-8000-000000000100"),
)
result = agent.run_sync("Hello")
print(result.output)
The adapter accepts the same run arguments as the wrapped PydanticAI agent. Kitaru workers provide task, replay, and authentication context through the standard task environment.
Model costs
The adapter estimates each completed LLM call's USD cost from its resolved model, provider, token usage, and request time. Pricing comes from the bundled genai-prices catalog. Unsupported models and providers leave the cost unset without failing the agent run. The recorded node attributes describe whether pricing was estimated or unavailable.
Supply cost_calculator for private models, negotiated rates, or provider billing rules. The callback receives a PydanticAIUsageSummary and returns a non-negative USD amount. A supplied callback takes priority over the bundled catalog.
from decimal import Decimal
from kitaru_pydantic_ai import KitaruAgent, PydanticAIUsageSummary
def calculate_cost(usage: PydanticAIUsageSummary) -> Decimal:
uncached_input = usage.input_tokens - usage.cached_input_tokens
return (
Decimal(uncached_input) * Decimal("0.000002")
+ Decimal(usage.cached_input_tokens) * Decimal("0.0000002")
+ Decimal(usage.output_tokens) * Decimal("0.000008")
)
agent = KitaruAgent(pydantic_agent, cost_calculator=calculate_cost)
Set estimate_costs=False when cost estimation should be disabled. This does not disable a supplied cost_calculator.
See the PydanticAI adapter guide for the recording lifecycle, replay overrides, tool policies, payload handling, and failure behavior.
Links
Licensed under Apache-2.0.
Metadata
Release files for kitaru-pydantic-ai 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kitaru_pydantic_ai-0.2.0.tar.gz | 15.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kitaru_pydantic_ai-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.6 kB
Release files / kitaru_pydantic_ai-0.2.0.tar.gz
| Download URL | kitaru_pydantic_ai-0.2.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b7567813a5860c34bb96d38bf4d3c1b00c263e0721991258e5c0c85490e9b97
|
|
BLAKE2b-256 checksum How to use checksums |
6309db8cc642c00dd6bd8b4bd3341525a95eb48122539a81f4827c0abe0edd22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / kitaru_pydantic_ai-0.2.0-py3-none-any.whl
| Download URL | kitaru_pydantic_ai-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cdef7665527e6cd32437fc95241a6d34f06c209818e43a48d871ae059b435ed
|
|
BLAKE2b-256 checksum How to use checksums |
2c0e6bb1c225870be73ccbe4db22bedde2f410283729d3ebcd63201e6a5fcee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency log