Skip to main content

llm-catalog-ai-sdk

AI SDK for Python 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 ai.Model — a gateway model is routed through your gateway via the core GatewayTransport, a direct model calls the vendor's own endpoint.

import json
from pathlib import Path

import ai
from llm_catalog.ai_sdk import AISDKCatalog

config = json.loads(Path("ai-sdk-catalog.json").read_text(encoding="utf-8"))

async with AISDKCatalog(config) as cat:  # closes its HTTP clients on exit
    model = cat.model_for_role("fast")
    params = cat.params_for_role("fast")
    async with ai.stream(model, [ai.user_message("hi")], params=params) as stream:
        async for event in stream:
            if isinstance(event, ai.events.TextDelta):
                print(event.chunk, end="", flush=True)

ai.Model carries no default call settings, so the catalog's merged settings come back separately from params_for_role() / params() as an ai.InferenceRequestParams to pass (or refine) per call. providerOptions is skipped: its entries are options of the TypeScript AI SDK providers and have no counterpart here.

Vendors and call surfaces

ai speaks three wire protocols directly, which covers three of the shared schema's vendors. Every other combination raises LLMCatalogError when the model is built; nothing is silently routed to a different API.

Vendor api omitted responses chat completion
anthropic Messages error Messages error
openai Responses Responses Chat Completions error
openai-compatible Chat Completions error Chat Completions error
any other vendor error error error error

chat on anthropic follows ai-sdk-catalog, where a single-surface vendor exposes chat as an alias of its one surface. google, mistral, groq, and the other vendors of the shared schema have no native protocol in ai; declare an endpoint that speaks Chat Completions as an openai-compatible vendor (or backend) instead. stopSequences has no stop parameter on the OpenAI Responses API, so it raises there rather than being dropped.

Beta notice

ai is in public beta and may change its API in any 0.x minor release. This adapter pins the ai minor lines it is tested against (currently 0.7.x to 0.9.x) and uses only ai's documented surface: ai.get_provider with base_url / api_key / client, ai.Model with an explicit protocol, and ai.InferenceRequestParams. Its tests send requests through ai to a mock transport, so an ai release that stops honouring the injected client fails CI instead of failing at runtime.

Requires Python 3.12+ (the floor of ai). The HTTP client is httpx2, which ai and the official OpenAI / Anthropic SDKs are built on; the header_rewrite / body_rewrite hooks 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). Installing this package pulls in neither pydantic-ai nor litellm.

See the repository README for the full picture and the verification notes (§9).

import namespace: llm_catalog.ai_sdk

Metadata

Release files for llm-catalog-ai-sdk 0.2.2

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-ai-sdk 0.2.2
File Size Uploaded Provenance Actions
llm_catalog_ai_sdk-0.2.2.tar.gz 11.6 kB Without provenance Details for llm_catalog_ai_sdk-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-catalog-ai-sdk 0.2.2
File Interpreter ABI Platform Actions
llm_catalog_ai_sdk-0.2.2-py3-none-any.whl Python 3 none any Details for llm_catalog_ai_sdk-0.2.2-py3-none-any.whl

Total release size: 24.2 kB

Release files / llm_catalog_ai_sdk-0.2.2.tar.gz

Download URL llm_catalog_ai_sdk-0.2.2.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a0dc2a2017320594999976ff82b077fb9c29132ba9f13fcaee7c5ed45284644e
BLAKE2b-256 checksum
How to use checksums
67f2db00fc39b76b40c80ede2fe8b8a249134befa5c36a0a336f508e62af7071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llm_catalog_ai_sdk-0.2.2-py3-none-any.whl

Download URL llm_catalog_ai_sdk-0.2.2-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4d2258e39e329ca60c2f16bed658781fad3245978907976558eaa937bd7b0c9
BLAKE2b-256 checksum
How to use checksums
9a5cce97bd68f139112194f27df6ccb6ba3a3030d9dd2124523f631cd273f86f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llm-catalog-ai-sdk 0.2.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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