Add Otari as an OpenAI-compatible gateway provider
Merged
TB
17d ago+457+457+012345678901234567890123456789-10-10-01234567890123456789
- Closes #13583
Adds OtariProvider for Otari, Mozilla.ai's open-source LLM gateway (hosted at otari.ai or self-hosted).
from pydantic_ai import Agent
agent = Agent('otari:anthropic:claude-sonnet-5-5') # OTARI_API_KEY, otari.ai US region
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.otari import OtariProvider
OpenAIChatModel('anthropic:claude-sonnet-5-5', provider=OtariProvider(region='eu'))
OpenAIChatModel('openai:gpt-5.2', provider=OtariProvider(base_url='http://localhost:8000/api/v1'))
OTARI_API_KEYfor the key, with no fallback toOPENAI_API_KEY.- Endpoint:
base_urlorregion('us'or'eu'), elseOTARI_BASE_URL, elsehttps://api.otari.ai/api/v1. Passing bothregionandbase_urlis a type error, and aUserErrorat runtime. - Model names are sent unchanged.
provider:modelandprovider/modelboth select the family profile throughvendor_family_model_profile, with overrides only for Otari ids that serve one vendor (azureopenai,gemini,moonshot). After a multi-vendor host (azure,bedrock,groq,together,vertexai, ...), avendor/modelid picks the family, as ingroq:openai/gpt-oss-120b; other names get no family profile. A routing policy or alias name gets the default OpenAI-compatible profile. - Registered as
otariininfer_provider_class,OpenAIChatCompatibleProviderand the special-token route table (not_EVERY_MODEL, since Otari also routes to closed models, as OpenRouter and Vercel do). When the name's provider part is a self-hosted server or an open-weight host (ollama,vllm,groq,together, ...), special tokens are escaped whatever the model's name. - Adding
'otari'toOpenAIChatCompatibleProviderneeds an API-compatibility waiver (every value accepted before still is; only an exhaustive match on the alias sees a new member). Fork PRs can't change.github/, so its content is in a comment below for a maintainer to add. - Package label: this belongs under
pkg:core, which I can't add from a fork. - Docs: an Otari section in
docs/models/compatible-apis.md, a provider-directory row, the API reference entry, and the agent skill's prefix list. - Tests:
tests/providers/test_otari.py(100% coverage of the module) and Otari entries in the shared provider-name, HTTP-client, special-token, agent re-entry, clai2 base-URL and examples tests.
Disclosure: I work on Otari at Mozilla.ai.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it. (None: additive only.)
- PR title is fit for the release changelog.
š¤ Generated with Claude Code
Summary by cubic
Adds the OtariProvider and StavProvider so agents can route through Otari, Mozilla.ai's open-source LLM gateway, or Stav's European inference gateway.
New Features
- Use
Agent('otari:anthropic:claude-sonnet-5-5')or build anOpenAIChatModelwithOtariProvider(region='eu')orOtariProvider(base_url=...);regionandbase_urltogether raise aUserError. - Use
Agent('stav:deepseek-ai/deepseek-v4-flash-0731')or build anOpenAIChatModelorOpenAIResponsesModelwithStavProvider(region='eu'); the region is sent as theX-Stav-Runs-Inheader. - Both providers read their own
*_API_KEYand*_BASE_URLenvironment variables, with no fallback toOPENAI_API_KEY. - Model names are sent unchanged; the provider prefix or
creator/modelid selects the family profile, and open-weight backends escape special tokens. - API-compatibility waivers cover the new
otariandstaventries inOpenAIChatCompatibleProviderandOpenAIResponsesCompatibleProvider.