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.6.0

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.6.0
File Size Uploaded
llm_catalog_pydantic_ai-0.6.0.tar.gz 10.1 kB Details

Built distribution (wheel)

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

Total release size: 22.0 kB

Release files / llm_catalog_pydantic_ai-0.6.0.tar.gz

Download URL llm_catalog_pydantic_ai-0.6.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
faa6e9a62fc5995d1f1a8592529b3c1fc8a4ed1fa40122feba4be8f1aeaaeefd
BLAKE2b-256 checksum
How to use checksums
bd5e099ef12b5de5f79e50ce9a7ec2ef0da425f1f7ddd8e49568a7fbfead8b5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.6.0-py3-none-any.whl

Download URL llm_catalog_pydantic_ai-0.6.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7521963e9d4a7223ff030d22e9995dfeeb065b7776a215f4cfd73cff549f6224
BLAKE2b-256 checksum
How to use checksums
880aa8ab2af2aba04a9a8c593c3b537076215a16931319745a6045b07c803c00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.0 This release

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