Add New Model
Wire a newly-released provider model into pydantic-ai. Optimized for the common case (mirror an existing sibling); flags the cases where it's not a mirror and needs deeper work.
Reference docs (read once before scoping)
agent_docs/pydantic-ai-slim.md — the Ownership section, plus pydantic_ai_slim/pydantic_ai/native_tools/AGENTS.md, for the user-visible surface this model needs to land on.
pydantic_ai_slim/pydantic_ai/profiles/AGENTS.md, providers/AGENTS.md, models/AGENTS.md, and pydantic_ai_slim/pydantic_ai/AGENTS.md (the capability-flag and Provider.model_profile() rules), plus the Design Rules section of agent_docs/pydantic-ai-slim.md. These tell you where capability facts belong (profile vs. provider vs. model class) when the new id has non-mirror behavior.
Inputs
User invokes with provider + model id (e.g. openai gpt-5.6). If missing, ask via AskUserQuestion.
Curation rule
The model-name Literal aliases (KnownModelName, each provider's *ModelName, and the image, embedding and
advisor aliases) list the models a user would pick. They are not catalogs. Apply this rule to every id you add:
- A line is a tier name: GPT
sol/terra/luna/astra, Claude opus/sonnet/haiku/fable, Gemini
pro/flash/flash-lite, and the Gemini 4 element names argon/carbon/hydrogen/neon. A new element
name starts a new line.
- A generation is the major version, counted per provider.
- Per line, list the newest id of the newest generation and the newest id of the previous generation. Within a
line, remove the older id the new one replaces, in the provider alias and in
KnownModelName.
- Leave out dated snapshots that have an undated alias, previews that a GA id superseded, floating
-latest
aliases (Mistral and TypeSafe excepted: their -latest ids are canonical), and non-chat models.
- On Bedrock, list one id per model: the
global. profile when it exists, else us., else the bare id.
- Keep every id that a model alias in
docs/model_aliases/aliases.json resolves to, even when the rule above
would drop it. tests/test_docs_model_aliases.py fails otherwise. Changing an alias target is a separate
decision under docs/model_aliases/AGENTS.md.
Profiles match any id, so removing an id from a literal changes autocomplete only. Never remove a profile branch
because its id left a literal.
Deprecated and retired models
A request to a model in pydantic_ai_slim/pydantic_ai/providers/_model_deprecations.py emits
DeprecatedModelWarning. When Anthropic or OpenAI announces a deprecation or retirement, update that file.
- Read the announcement on Anthropic's or
OpenAI's deprecations page. Never write an entry from memory.
- Add or update the entries as the module docstring's rules say.
- Run the test files that use each newly listed id. A test that replays a recording or mock on that id now fails
with
DeprecatedModelWarning. Add the id to DEPRECATED_MODELS_IN_RECORDINGS in tests/conftest.py, in the group
for its announcement, with the retirement date and the provider's tracking issue. Add the id to that issue's
checklist.
- A test that sets its own warnings filter, such as
simplefilter('always') or simplefilter('error'), overrides
replay_deprecated_models. Leave DeprecatedModelWarning out of what that test asserts instead.
- Run
tests/models/test_deprecated_model_warning.py and tests/profiles/test_resolution_matrix.py.
Image generation models
Image-only models use a separate public surface from conversational models. If the model is consumed by ImageGenerator, update KnownImageGenerationModelName in pydantic_ai_slim/pydantic_ai/images/__init__.py, the relevant direct provider adapter, and its tests; do not also change conversational KnownModelName, profiles, gateway aliases, ImageGenerationTool, or models/<provider>.py unless that surface is explicitly supported and in scope. Add only the public model IDs the project intends to support, and do not infer or automatically add dated snapshots.
Keep common, provider-agnostic controls in images/settings.py, but import provider-specific setting types from the official SDK. Put model-specific size and aspect-ratio validation or mapping in the private images/_<provider>_geometry.py helper, and update the public support matrix in docs/image-generation.md. Verify geometry against official documentation; if the provider does not publish exact output shapes, probe every documented aspect-ratio and resolution combination for every supported model and record the evidence. Prefer deterministic table tests for the full matrix, adding one representative VCR cassette only when the new model or wire behavior needs integration coverage rather than recording every image combination.
Step 1 — Verify the model exists at the provider
Never trust marketing names, news articles, or guesses. Hit the provider's model-listing endpoint:
| Provider |
Verification call |
| OpenAI |
curl -s https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" |
| Anthropic |
curl -s https://api.anthropic.com/v1/models -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" |
| xAI |
curl -s https://api.x.ai/v1/models -H "Authorization: Bearer $XAI_API_KEY" |
| Google |
curl -s https://generativelanguage.googleapis.com/v1beta/models -H "x-goog-api-key: $GOOGLE_API_KEY" |
| Groq |
curl -s https://api.groq.com/openai/v1/models -H "Authorization: Bearer $GROQ_API_KEY" |
| Bedrock |
aws bedrock list-foundation-models --region "$AWS_REGION" |
Load credentials from the repo-root .env with source .env && <cmd>. list-foundation-models is region-scoped, so query the region your models are actually deployed in (not a hard-coded default). List every id the provider exposes for this release — base, dated snapshot, -pro, -mini, -nano, -codex, -chat-latest. Add only what actually exists; do not extrapolate sibling variants.
If the user-given id is not in the listing, stop and confirm with the user before proceeding.
Step 2 — Mirror the most recent add-model PR for this provider
git log --all --oneline --grep="<previous-version-pattern>" -20
# e.g. for openai: --grep="gpt-5\.4\|gpt-5\.3"
# e.g. for anthropic: --grep="claude-opus-4\|claude-sonnet-4"
Pick the smallest, most recent "add model X" PR for the same provider. Pull its file list with gh pr view <num> --json files --jq '.files[].path'. That file list is the floor of what you'll touch. It is rarely the ceiling.
Step 3 — Enumerate (load-bearing step)
For every variable, tuple, and literal you're about to touch, grep its readers across the repo. This step is what catches the snapshot/enumeration tests that ratchet on every model add. Skipping it pushes work onto CI and produces broken PRs.
Specifically, for a typical model add, grep for:
- The previous model id literal you're mirroring (e.g.
gpt-5.4, claude-opus-4-5) — rg '<prev-id>' --glob '!**/*.yaml' --glob '!**/cassettes/**'
- Search for the previous model's display name in docs and public docstrings; inspect capability rosters for the same features.
- Every prefix/membership key in the profile module you're editing (e.g. OpenAI's
_REASONING_SUPPORT_BY_PREFIX keys, Anthropic's inline model_name.startswith((...)) tuples, xAI's _GROK_43_REASONING_MODELS)
KnownModelName and its provider-block neighbours
- Snapshot test files:
tests/models/test_model_names.py, tests/test_capability_spec.py
- Public API compatibility: the release comparison reports a model-name
Literal change as an attribute-value change. The gate passes added and removed names on an alias listed under model_name_literals in .github/api-compatibility-allowlist.json. Do not add a waiver for that change: the gate fails on an unused waiver. If the gate fails on a model-name alias that is not listed, add its path and symbol to model_name_literals. Any other change to the alias, such as adding a non-Literal arm, needs an exact waiver.
Classify each hit:
- must update — model-name lists, dispatch tuples
- snapshot to refresh —
inline_snapshot blocks needing pytest --inline-snapshot=fix
- skip — VCR cassettes, docs about an unrelated model
If rg output looks mangled (unicode/regex artifacts), drop to grep -n — don't push past garbled output.
Step 3b — Verify pricing and context data
Pricing additions belong to the automated workflows in pydantic/genai-prices.
The Update prices workflow
imports provider data hourly and aggregator data weekly.
Genie Pricer
handles targeted model additions through the
Model Price Check workflow.
Do not open or implement a manual genai-prices counterpart PR during a model add.
Do not trigger a pricing request unless the user authorizes that request.
Verify the exact API IDs and hosting providers independently of pricing data.
Do not infer availability from an older sibling or a pricing match.
Do not block model-name support on pricing-feed lag.
Cost and context_window data come from pydantic/genai-prices through _genai_prices.py.
Bundled data requires a genai-prices release.
Check both the installed package and the live merged feed for the exact model.
Update the Pydantic AI lock when adopting a package release with the entry.
The live merged feed can supply entries through pydantic_ai.prices.update_in_background().
Check the updater for an entry before claiming a package release blocks support.
Model.profile only consults genai-prices when nothing else set context_window.
Without a price entry in either source, ModelResponse.cost() raises LookupError and a
cost_limit cannot be enforced — the run warns CostNotFoundWarning at the end instead.
Without a context_window value from any source, RunContext.context_window_used is None.
Compare matched prices against the provider's official rates; a broad sibling match can silently return stale prices.
Report missing or incorrect data and link an existing automation proposal when available.
Step 4 — SDK pin check
The OpenAI, Anthropic and xAI aliases are curated Literals, not the SDK's model literal. tests/models/test_model_names.py
ties the two together through SDK_MODEL_LITERALS:
test_sdk_model_literal snapshots each SDK's full model literal at the version in uv.lock. It skips on CI legs
that install another version (lowest-versions, the upgrade canary).
test_curated_model_names_are_sdk_ids_or_bridges requires every curated id to be in the locked SDK's literal or in
that entry's bridges, and every bridge to be absent from the SDK.
Check whether the locked SDK lists the new id:
uv run python -c "from openai.types import AllModels; from typing import get_args; print([m for m in get_args(AllModels) if '<new-version>' in m])"
Anthropic reads anthropic.types.ModelParam, xAI reads xai_sdk.types.model.ChatModel, and the image and embedding
entries read the SDK types SDK_MODEL_LITERALS names. If the locked SDK lacks the id, add the id to that entry's
bridges. Remove the bridge in the PR that bumps the SDK past the release that lists it.
When a uv.lock upgrade changes an SDK's model literal, test_sdk_model_literal fails. Review the new ids against
the curation rule, update the curated alias and KnownModelName, drop any bridge the SDK now lists, then run
uv run pytest tests/models/test_model_names.py --inline-snapshot=fix.
If a release lists the id but sits inside the 7-day exclude-newer window, bridge it. For Anthropic, the SDK-bump
bullet in its landmine section decides between bump and bridge.
Step 5 — Probe capabilities (only if not a pure mirror)
If the new model is just another sibling in an existing family (e.g. gpt-5.5 after gpt-5.4), skip to Step 6 — the existing profile branch covers it once you add the prefix to the dispatch tuple.
If the model is a new family or has unclear capabilities, write a small comparison script (local-notes/probe_<model>.py) that hits the new model AND its closest neighbour with:
temperature / top_p (does the API reject sampling params?)
reasoning.effort values (none, minimal, low, medium, high, xhigh, max) — note which the API accepts. OpenAI's 400 lists the accepted values. Probe max on both the Responses and Chat Completions APIs: they accept different sets, recorded in openai_responses_supports_max_reasoning_effort (set in OpenAIProvider.model_profile) and openai_chat_supports_max_reasoning_effort (set in each OpenAI-compatible provider's model_profile)
- New parameters mentioned in the release notes
- Streaming / tool calls if the family is new
Diff the responses. Anything that diverges from the neighbour belongs in the profile.
Gateway parity
Where the gateway serves a model, it must behave the same as the provider's canonical API. Step 3 only
gets the id recognized; this is about behavior, and nothing enumerates it for you.
The gateway reaches the canonical API through an ordinary SDK client carrying a proxy base URL. So:
- Narrow a capability by client class, never by base URL. Bedrock, Vertex and Foundry are separate
transports and earn their own gates. A proxied client is the canonical API, and must keep every
capability the unproxied one has.
- A
base_url test inside a capability decision is the defect, not the fix. It splits the gateway
off from the transport it actually reaches. No capability in models/ or profiles/ is decided that
way — if you are about to be the first, you are answering the wrong question.
- Probe the gateway leg rather than reasoning about it.
Model('<id>', provider='gateway'), then
exercise whatever capability you gated. If PYDANTIC_AI_GATEWAY_BASE_URL is set in the environment,
check it points at the gateway root: a provider-specific proxy path 404s every other provider.
Step 6 — Edit (minimal diff matching the mirrored PR)
Make only the changes the enumeration step surfaced. Resist scope creep. If you suspect a pre-existing bug in a sibling model's profile, reproduce it live first. Fold a reproduced bug on the same profile gate into this PR, with a test and one PR-body line. Flag an unreproduced or larger one in the PR description instead.
Assume the Gateway serves every new id on a provider it proxies. Add each id's gateway/ mirror to KnownModelName without probing the Gateway first. Never add a new id to UNSUPPORTED_GATEWAY_MODEL_NAMES. Until genai-prices has the id's price, the Gateway can refuse it with a 404 No cost data available for model; that gap closes without a Pydantic AI change. File one tracking issue per release instead, to confirm that the Gateway serves and prices each new id. Route it with the maintainer routing in the file-followup-issue skill. List every id of the release in it, including ids the curation rule keeps out of KnownModelName. List each Bedrock region prefix as its own id: Gateway support for one inference profile does not establish support for another. Name the weekly Gateway Model Health workflow (.github/workflows/gateway-model-health.yml) in the issue: it runs every gateway/ id in KnownModelName live. Exclude an id only in a separate change, after the tracking issue confirms that the Gateway refuses it.