Metadata-Version: 2.4
Name: llm-catalog-pydantic-ai
Version: 0.6.0
Summary: Pydantic AI adapter for llm-catalog: build native Pydantic AI models from a catalog config, routed through your gateway.
Keywords: llm,catalog,pydantic-ai,gateway
Author: Shinsuke Mori
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Dist: llm-catalog-core[httpx2]>=0.9.0,<0.10
Requires-Dist: pydantic-ai>=2.51
Requires-Dist: httpx2>=2.7
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/sincekmori/llm-catalog
Project-URL: Repository, https://github.com/sincekmori/llm-catalog
Project-URL: Issues, https://github.com/sincekmori/llm-catalog/issues
Project-URL: Changelog, https://github.com/sincekmori/llm-catalog/blob/main/packages/llm-catalog-pydantic-ai/CHANGELOG.md
Description-Content-Type: text/markdown

# llm-catalog-pydantic-ai

[Pydantic AI](https://ai.pydantic.dev) adapter for [llm-catalog](https://github.com/sincekmori/llm-catalog).
It turns a role in your catalog config (`ai-sdk-catalog.json`, shared verbatim with `ai-sdk-catalog`) into a native Pydantic AI `Model` — a gateway model is routed through your gateway via the core `GatewayTransport`, a direct model calls the vendor's own endpoint (anthropic / openai / openai-compatible / google).

```python
import json
from pathlib import Path

from pydantic_ai import Agent
from llm_catalog.pydantic_ai import PydanticAICatalog

config = json.loads(Path("ai-sdk-catalog.json").read_text(encoding="utf-8"))
cat = PydanticAICatalog(config)  # validates the config itself
agent = Agent(cat.model_for_role("fast"))
```

Each model is built once and reused, with its own HTTP client, so repeated `model_for_role()` calls share a connection pool.
Close the clients with `await cat.aclose()` when you are done, or use the catalog as `async with PydanticAICatalog(config) as cat:`.

Installing this package does not pull in `litellm`.
The distributions are deliberately split so a Pydantic AI user's lockfile never references it.

Requires Python 3.12+ and `pydantic-ai>=2.51`.
The HTTP client is [`httpx2`](https://github.com/pydantic/httpx2): Pydantic AI and the SDKs it wraps (`openai>=3`, `anthropic>=1`) are built on it, and the Anthropic SDK rejects an `httpx` client outright.
The `header_rewrite` / `body_rewrite` hooks therefore receive `httpx2.Headers` / `httpx2.Request`.
Pass `transport_factory` to supply the underlying `httpx2` transport yourself (a proxy, mTLS, connection limits, or `httpx2.MockTransport` in tests).

See the [repository README](https://github.com/sincekmori/llm-catalog) for the full picture and the verification notes (§9), including the google-genai / custom-HTTP-client caveat.

import namespace: `llm_catalog.pydantic_ai`
