Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kitaru_pydantic_ai-0.1.0rc0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kitaru_pydantic_ai-0.1.0rc0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file kitaru_pydantic_ai-0.1.0rc0.tar.gz.

File metadata

  • Download URL: kitaru_pydantic_ai-0.1.0rc0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for kitaru_pydantic_ai-0.1.0rc0.tar.gz
Algorithm Hash digest
SHA256 faa28dbdd035e266236ba9e7d376f3cd8498b30ef54555125bfa920c9c974f97
MD5 463be4f3519d4cc65d49247ec5fea2f8
BLAKE2b-256 5da60e37966dd09e7d5b3c5c73c20c3bf23824e2f5060008c3682b5756da0501

See more details on using hashes here.

Provenance

The following attestation bundles were made for kitaru_pydantic_ai-0.1.0rc0.tar.gz:

Publisher: release-plugins.yml on zenml-io/kitaru

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kitaru_pydantic_ai-0.1.0rc0-py3-none-any.whl.

File metadata

File hashes

Hashes for kitaru_pydantic_ai-0.1.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 8acf3d1d87e1d1b5ea110e7fa9ddf16300268f17095e7b91e548a428ccd0cfe1
MD5 01d554983cea58961c648ba0c5657a8d
BLAKE2b-256 596ebd9ab53389f8949c124a87fc231e73360938315995c8f0a118424c288901

See more details on using hashes here.

Provenance

The following attestation bundles were made for kitaru_pydantic_ai-0.1.0rc0-py3-none-any.whl:

Publisher: release-plugins.yml on zenml-io/kitaru

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page