Skip to main content

llm-catalog-pydantic-ai

Pydantic AI adapter for 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).

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: 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 for the full picture and the verification notes (§9), including the google-genai / custom-HTTP-client caveat.

import namespace: llm_catalog.pydantic_ai

Metadata

Release files for llm-catalog-pydantic-ai 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-catalog-pydantic-ai 0.7.1
File Size Uploaded
llm_catalog_pydantic_ai-0.7.1.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-catalog-pydantic-ai 0.7.1
File Interpreter ABI Platform
llm_catalog_pydantic_ai-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / llm_catalog_pydantic_ai-0.7.1.tar.gz

Download URL llm_catalog_pydantic_ai-0.7.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c71f6f930a5661974927a0160b061d12830d63bdacd63056a1b0880fbe56f9f
BLAKE2b-256 checksum
How to use checksums
e0e4bc13f392b6815aeb50df88af8691f75ac27a2a7986ae2f42b5ef06483ea8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llm_catalog_pydantic_ai-0.7.1-py3-none-any.whl

Download URL llm_catalog_pydantic_ai-0.7.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97150c740bde8f05cae738238dcac7a7510b0b7efe80b37341b833fca4a282f7
BLAKE2b-256 checksum
How to use checksums
a1201662e3830f9639a3583fe85b59030b70bc749fed2d7085a51aedbe00ccac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page