add-new-model
Add support for a newly-released language or image generation model in pydantic-ai (e.g. openai:gpt-5.6, anthropic:claude-sonnet-5, openai:gpt-image-2). Use when a provider ships a new model id and you need to wire literals, profile flags, adapters, and tests to recognize it. Handles SDK-lag, gateway list conventions, capability probing, and direct image-model geometry.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 2.1w
- Forks
- 3.1k
01 前言 Front Matter
- name
- add-new-model
- description
- Add support for a newly-released language or image generation model in pydantic-ai (e.g. openai:gpt-5.6, anthropic:claude-sonnet-5, openai:gpt-image-2). Use when a provider ships a new model id and you need to wire literals, profile flags, adapters, and tests to recognize it. Handles SDK-lag, gateway list conventions, capability probing, and direct image-model geometry.
- allowed-tools
- Bash, Read, Edit, Write, Glob, Grep, WebFetch, WebSearch, AskUserQuestion
- user-invocable
- true
03 SKILL.md 正文
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, pluspydantic_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, andpydantic_ai_slim/pydantic_ai/AGENTS.md(the capability-flag andProvider.model_profile()rules), plus the Design Rules section ofagent_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, Claudeopus/sonnet/haiku/fable, Geminipro/flash/flash-lite, and the Gemini 4 element namesargon/carbon. - 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. 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
-latestaliases (Mistral and TypeSafe excepted: their-latestids are canonical), and non-chat models. - On Bedrock, list one id per model: the
global.profile when it exists, elseus., else the bare id. - Keep every id that a model alias in
docs/model_aliases/aliases.jsonresolves to, even when the rule above would drop it.tests/test_docs_model_aliases.pyfails otherwise. Changing an alias target is a separate decision underdocs/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.
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" |
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_PREFIXkeys, Anthropic's inlinemodel_name.startswith((...))tuples, xAI's_GROK_43_REASONING_MODELS) KnownModelNameand 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
Literalchange as an attribute-value change. The gate passes added and removed names on an alias listed undermodel_name_literalsin.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 itspathandsymboltomodel_name_literals. Any other change to the alias, such as adding a non-Literalarm, needs an exact waiver.
Classify each hit:
- must update — model-name lists, dispatch tuples
- snapshot to refresh —
inline_snapshotblocks needingpytest --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_literalsnapshots each SDK's full model literal at the version inuv.lock. It skips on CI legs that install another version (lowest-versions, the upgrade canary).test_curated_model_names_are_sdk_ids_or_bridgesrequires every curated id to be in the locked SDK's literal or in that entry'sbridges, 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.effortvalues (none,minimal,low,medium,high,xhigh,max) — note which the API accepts. OpenAI's 400 lists the accepted values. Probemaxon both the Responses and Chat Completions APIs: they accept different sets, recorded inopenai_responses_supports_max_reasoning_effort(set inOpenAIProvider.model_profile) andopenai_chat_supports_max_reasoning_effort(set in each OpenAI-compatible provider'smodel_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_urltest inside a capability decision is the defect, not the fix. It splits the gateway off from the transport it actually reaches. No capability inmodels/orprofiles/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. IfPYDANTIC_AI_GATEWAY_BASE_URLis 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.
Assume Bedrock serves a new id that AWS gates per account. AWS can list a model in aws bedrock list-inference-profiles while Converse still answers AccessDeniedException: ... is not available for this account. List the id anyway, as the curation rule picks it: the global. profile when it exists. Leave the capability gates in providers/_bedrock_model_names.py on their existing prefixes. File one Bedrock tracking issue for the probes to run once AWS grants access. Route it with the maintainer routing in the file-followup-issue skill. List these probes in it:
- The id serves through
BedrockConverseModeland the Bedrock Messages API. - Each gate whose prefix decision contradicts the AWS model card or Anthropic's Bedrock docs.
Change a gate only after its probe passes. A GPT id on bedrock: is the exception: list it only after a successful Converse call, as the Bedrock landmines say.
Docs examples name models through the aliases in docs/model_aliases/aliases.json, not model ids. Check the placement rules in docs/model_aliases/AGENTS.md. When they place the new model in an alias, repoint that alias in aliases.json instead of editing doc pages. Repoint it in the same PR; do not wait for the Gateway to serve the new id. Then update the README mirrors that tests/test_docs_parity.py and tests/harness/test_docs_parity.py flag. The harness capability READMEs and their _capability.py docstrings mirror doc pages that use the alias but are not parity-tested: git grep the old id and update those mirrors too.
After edits:
make format && make lint
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 uv run pyright <changed-python-files>
Run the tests directly touching the changed surface — the profile test plus any enumeration tests you updated. CI is the safety net for the long tail; locally you only need to verify the surface area of your change.
If snapshot tests changed: uv run pytest <file> --inline-snapshot=fix then verify the diff is the expected literal addition only.
Step 7 — VCR / integration tests
Default for mirror-only adds: skip recording a new VCR. Repo convention uses one representative model per family for VCR (e.g. gpt-5.2 covers the gpt-5.x reasoning family). The profile unit test added in Step 6 is sufficient.
When the new model introduces meaningful changes to pydantic_ai_slim/pydantic_ai/models/<provider>.py (new request shape, new response field, new handler branch):
- Look for an existing parametrized VCR test that covers the changed feature.
rg -l '<feature-name>' tests/models/. If one exists and it parametrizes over model ids, tag the new id onto the parametrize list rather than writing a new test. - If no parametrized coverage exists and you need a new VCR test, place it:
- Prefer
tests/models/<provider>/test_<feature>.pyonly if the file already exists (e.g.tests/models/anthropic/test_output.py). - Otherwise add it to
tests/models/test_<provider>.py. Do not create a newtests/models/<provider>/subdirectory if one doesn't already exist for this provider.
- Prefer
- Record using the
testing-skillskill workflow.
Step 8 — PR
Follow the pushing-commits-to-the-repo skill for the title, body, template, and final metadata
check. Keep the model-specific evidence concise:
- One sentence: what model(s) were added.
- "Verified via probe / mirror of #NNNN" — explicit about which changes were API-verified vs assumed-by-mirror.
- Flag pre-existing latent bugs found but deliberately not fixed.
- Link the prior add-model PR for context.
- Link the Gateway tracking issue from Step 6, and the Bedrock tracking issue when Step 6 filed one.
Provider-specific landmines
OpenAI
_REASONING_SUPPORT_BY_PREFIXinpydantic_ai_slim/pydantic_ai/profiles/openai.py— a dict keyed by model-name prefix ('gpt-5.6','gpt-5.3-chat','gpt-5','o', …) →_ReasoningSupport(enabled_by_default, can_be_disabled, supports_mode, supports_context), resolved first-match-wins by_reasoning_support(). A newgpt-5.Nfamily MUST be added here, and ordering matters: a more specific prefix ('gpt-5.3-chat') must precede the broader one it would otherwise shadow ('gpt-5.3'), and every newergpt-5.xfamily must precede the plain'gpt-5'catch-all. Miss it and the model falls through to the_NO_REASONINGdefault (thinking_always_enabled=False,openai_supports_reasoning_effort_none=False) — wrong defaults, no error. The resolved matrix is pinned intests/profiles/test_openai.py.KnownModelNamelives inpydantic_ai_slim/pydantic_ai/models/_known_model_names.py(aTypeAliasType), notmodels/__init__.py. Add the id to itsopenai:,openai-chat:andgateway/openai:entries, and remove the ids the curation rule retires.- Most
gpt-5.x-chatvariants DO reason (_ALWAYS_ON_REASONING: reason at a fixed effort, rejectreasoning_effort='none'and sampling parameters). The non-reasoning exception is the originalgpt-5-chat/gpt-5-chat-latest(_NO_REASONING). Verify each-chat/-chat-latestvariant against the live Responses API; don't copy a sibling's reasoning class blindly. -provariants map to_ALWAYS_ON_REASONING(gpt-5.2-pro,gpt-5.4-pro,gpt-5.5-pro) — they reason and rejecteffort='none'._ReasoningSupportdoesn't encode per-effort-value rejection, so if a new-prorejects a specific value (e.g.'low'), flag it rather than assuming the enum covers it.tests/models/test_model_names.py::test_known_model_namesassertsknown_model_names()equals the set the curated aliases generate, gateway mirror included. Step 4's bridge check readsAllModels(the broad union, not the chat-onlyChatModel).tests/test_capability_spec.py::test_model_json_schema_with_capabilitiesis a snapshot test enumerating everyKnownModelName. Refresh with--inline-snapshot=fix.- A dotted point release matches none of its family's prefixes.
gpt-6.1-soldoes not start with'gpt-6-sol'. Before you add it, it resolves to_NO_REASONINGand misses everystartswithgate inopenai_model_profile(). Add it to_REASONING_SUPPORT_BY_PREFIXand to the generation's gate tuple (_GPT_6_MODEL_PREFIXES). - Probe a point release against every sibling, not only its namesake. GPT-6.1 Sol rejects
effort='none'like GPT-6 Astra; GPT-6 Sol accepts it. The accepted-effort list decidescan_be_disabled. Decidesupports_image_outputby forcing the tool (tool_choice={'type': 'image_generation'}), not from the model page's tool list. - Chat Completions rejects function tools while reasoning is on for the GPT-6 family:
Function tools with reasoning_effort are not supported. A model that rejectseffort='none'therefore has no Chat Completions tool calling. Document the limit indocs/models/openai.md. - clai2 keeps a curated Codex menu:
CODEX_MODELSinsrc/pydantic_clai2/pydantic_clai2/model_catalog.py. Add the id when Codex offers it. Checkopenai/codex'scodex_tui__chatwidget__tests__model_selection_popup.snap, then runAgent('openai-codex:<id>')with a local Codex login. Update the Codex model lists insrc/pydantic_clai2/README.md(two of them),src/pydantic_clai2/PLUGINS.mdanddocs/harness/clai2.md:rg 'openai-codex:gpt-|gpt-5.6-luna' src/pydantic_clai2 docs/harness.
OpenAI image-model landmines:
- Probe
qualitywith a validsize. The Images API validatessizebeforequality. An unknownqualityreturns the samelow, medium, high, autolist for every model, so it tells you nothing. Only a request that passes size validation shows the per-model rejection:The model 'gpt-image-2' does not support quality 'xhigh'. - Probe geometry with out-of-bounds sizes. The API rejects a size before it generates anything. When the new model rejects each boundary size with the same message as a known family, add its ids to that family's tuple in
images/_openai_geometry.py. - A model page's "Responses: Not supported" means the top-level
model. GPT Image 2.6 pages say it, yet the Responsesimage_generationtool accepts both 2.6 ids. Probe the tool withtool_choice={'type': 'image_generation'}before decidingImageGenerationModelName.
Anthropic
- TWO literal lists, not one. Add the id to BOTH:
pydantic_ai_slim/pydantic_ai/models/_known_model_names.py— theanthropic:ANDgateway/anthropic:blocks (theKnownModelNamealias moved here frommodels/__init__.pyin #5803; older add-model PR diffs that edit__init__.pyare stale on this point).LatestAnthropicModelNamesinmodels/anthropic/__init__.py— see the SDK-lag bridge below.
- Anthropic names are enumeration-tested.
LatestAnthropicModelNamesis the curatedLiteral;test_known_model_namesties it toKnownModelName. - SDK-lag bridge (the Step 4 mechanism for Anthropic when the locked SDK lacks the id). When the locked SDK's
anthropic.types.ModelParamdoesn't list the new id, add it to theanthropicentry'sbridgesinSDK_MODEL_LITERALS.ModelParam≠anthropic.types.model.Model; checkModelParam. - Capability flags live as
startswithprefix tuples inprofiles/anthropic.pyinsideanthropic_model_profile()(+ the module-level_ANTHROPIC_CODE_EXECUTION_20260120_MODEL_PREFIXES). A new family is NOT a literal-only add — it almost always needs at least one profile override (a literal-only add is only right when the family truly inherits every default branch, which is rare). Probe and set each independently:models_that_support_json_schema_output,supports_adaptive,supports_effort,supports_xhigh_effort,disallows_budget_thinking,disallows_sampling_settings,supports_task_budgets,supports_tool_search, code-exec version,anthropic_supports_fast_speed. Default-Falseflags (e.g. fast speed) are subtractive — just omit the id from that tuple. - A point release inherits every flag of its base id silently. The tuples are
startswithprefixes, so'claude-opus-5'already matchesclaude-opus-5-5(as'claude-fable-5'matchesclaude-fable-5-1): before you touch anything, the new id resolves to the base model's profile. Tests stay green and nothing warns, so the only way to find a divergence is to read the model's migration guide and probe side by side with the base id. Opus 5.5 looked like an Opus 5 mirror and broke defaultoutput_typeruns with a 400 until it opted out of forcing. Where a flag must not carry over, carve the id out explicitly (startswith('claude-opus-5') and not startswith('claude-opus-5-5')). - Read the migration guide's "breaking changes" before probing. Anthropic's
platform.claude.com/docs/en/models/<id>/migration-guideandwhats-new-<id>pages list every divergence from the previous model and name which other models share it (e.g. "the first three also apply on Claude Fable 5.1"). Those map straight onto profile flags, and they tell you what to probe. - Bump the SDK through the 7-day quarantine rather than bridging, once a release of the locked SDK major lists the id. When only a newer major lists it, bridge the id instead: a bump would raise the floor to that major and move every Anthropic user onto it.
exclude-newer = "7 days"in the rootpyproject.tomlkeeps a same-dayanthropicrelease out of the lock; admit exactly that release with a timestamp cutoff under[tool.uv.exclude-newer-package](one second past its last artifact's PyPIupload_time, plus aTODOto remove it once the global window covers it — past that date it turns into a ceiling), raise the floor undertool.hatch.metadata.hooks.uv-dynamic-versioning.optional-dependenciesinpydantic_ai_slim/pyproject.toml(move the exactuv add --optional-generated requirement there, add a comment above it naming what the code now needs from that version, as theanthropicandxai-sdkfloors there have, and remove its conflicting[project.optional-dependencies]table), runuv lock --upgrade-package anthropic, and refresh the gh-aw runner's own lock withuv lock --script .github/scripts/pydantic-ai-runner. File a tracking issue for removing the cutoff and link it from theTODO. Precedents: #7989 (1.3.0), #8637 (1.8.0). Thebridgesentry above covers every case where the locked SDK lacks the id and no bump applies. - An SDK bump is a real change: pyright
models/anthropic/and the Anthropic tests against it. 1.8.0 renamed the citations request TypedDict toBetaCitationsConfigParamParam(BetaCitationsConfigParambecame a response model, and passing it into a request param broke a dict assertion) and widenedBetaInputTransformationto a union withthinking_mismatch_allowed. - Opus 5.5 skips thinking on trivial prompts at its default
mediumeffort. A cassette test that needs a thinking block (e.g.stale_thinking_block_history) has to raiseanthropic_effortfor it. - A point release falls into its base model's price entry. The base entries' prefix and
containsclauses (starts_with: claude-opus-5) also captureclaude-opus-5-5. So until the new entry exists,calc_pricereturns the old model's price with no error: genai-prices 0.1.7 priced Opus 5.5 at Opus 5's $5/$25 instead of $4/$20. Checkcalc_price(..., model_ref='<new-id>')against the published price. Report an incorrect sibling match to the pricing automation owner per Step 3b. Link genai-prices #671 and #709 for the match-boundary regression pattern. - Forced
tool_choiceis a real per-model divergence worth probing. Most Anthropic models accepttool_choice{'type':'any'}/{'type':'tool'}and only reject forcing alongside thinking; Claude Fable 5.1, Claude Mythos 5.1, and Claude Opus 5.5 reject it unconditionally (400tool_choice forces tool use is not compatible with this model). That's modeled byAnthropicModelProfile.anthropic_supports_forced_tool_choice(defaultTrue) threaded into_support_tool_forcinginmodels/anthropic/__init__.py. Probetool_choice={'type':'any'}against the new id AND its neighbour to tell a genuine divergence from a thinking-only constraint. - Record the automatic stale-thinking-block retry for a model that runs the prefix check on every account. The recording account predates the 2026-08-31 enforcement cutoff, so on Claude Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5 a default request never reaches the retry. Claude Fable 5.2 and Mythos 5.2 enforce the check on every account. Probe the new id with
prefix_mismatch_behaviorunset after asystemchange: a 400 means the retry path runs live. Precedent:test_anthropic_fable_5_2_retries_a_stale_thinking_block_on_a_legacy_account. - Keep Mythos ids out of
LatestAnthropicModelNames. Mythos models are open only to verified organizations; our key gets a 404not_found_errorfor them. Add a new Mythos id to each profile tuple that names its Fable sibling explicitly, on the evidence of Anthropic's published docs, and say so in the PR. - Probe the stale-thinking-block retry shape on every new binding model. When the request set no thinking, the retry sends a
thinkingobject throughextra_body. Claude Fable 5.1 and Claude Opus 5.5 accept{'block_binding': ...}alone; Claude Sonnet 5.5 rejects it withthinking.type: Field required, so the retry fills in'type': 'adaptive'. Probeextra_body={'thinking': {'block_binding': {'prefix_mismatch_behavior': 'drop_block'}}}against the new id. Also probe any newthinking.typethe release adds withblock_binding: Sonnet 5.5'sbetween_toolsrejects it (Extra inputs are not permitted), so the retry skips that type. - Probe a mid-conversation
systementry against the<system>-tagged fallback before touching_INLINE_SYSTEM_PROMPT_MODEL_PREFIXES. Ask each rendering to lift a restriction the top-level prompt set; a plain non-conflicting instruction lands on every model and discriminates nothing. Claude Opus 5 obeys the entry 6/6 and the tagged text 0/6. Claude Sonnet 5.5 refuses both 6/6, so Anthropic's published support decides and it stays in: the entry keeps operator authority at no measured cost. Leave an id out only when the tagged fallback does measurably better, as it did on Claude Sonnet 5._TOOL_AVAILABILITY_DELTA_MODEL_PREFIXESis a separate gate: probe atool_additionby reference and check that the model calls the added tool. - List Bedrock inference profiles, not only foundation models. Claude Sonnet 5.5 launched with
global.anthropic.claude-sonnet-5-5and nous.profile. Runaws bedrock list-inference-profilesand add only the profiles it returns. - Tests: profile-flag unit tests go in
tests/profiles/test_anthropic.py(NOTtests/models/test_anthropic.py). Forced-tool-choice /_prepare_tools_and_tool_choicefallback tests go intests/models/test_tool_choice_unit.py. The capability behaviors keyed on shared flags (sampling drop, budget-thinking reject, xhigh) are already covered by the opus-4-7/4-8 parametrized tests — adding the new id to those lists is redundant once a dedicated profile test asserts the flags. tests/test_capability_spec.py::test_model_json_schema_with_capabilitiessnapshots the wholeKnownModelNameenum. Refresh it by running THAT TEST ALONE with--inline-snapshot=fix— running the whole file can pull in unrelatedsnapshot()blocks and abort the fix.providers/_bedrock_model_names.pybedrock_lacks_claude_structured_output: only relevant if the new id is actually served on Bedrock. A direct-API-only model (not in Bedrock's foundation-model list) doesn't belong there; don't add it speculatively just because the mirrored PR did.
xAI (Grok)
XaiModelNameis a curatedLiteral.test_known_model_namesties its ids to thexai:entries inmodels/_known_model_names.py.- SDK-lag bridge.
xai_sdk'sChatModelfrequently lags a release, so bumping the floor often won't help (check newer wheels first: download from PyPI and grepxai_sdk/types/model.pyforChatModel: TypeAlias = Literal[). Add the id to thexaientry'sbridgesinSDK_MODEL_LITERALS. - A new
grok-4.xis NOT a pure mirror. Reasoning-effort support lives inprofiles/grok.pyas membership sets (_GROK_43_REASONING_MODELS+ a per-family effort frozenset), not startswith prefixes. Thegrok-4prefix auto-grantsgrok_supports_builtin_tools=Truebut leavesgrok_reasoning_effortsempty (→supports_thinking=False) unless you add the id to a reasoning-models set. Forgetting this silently ships a reasoning model with thinking off. Add a_GROK_<ver>_REASONING_MODELSset + effort frozenset and anelifbranch ingrok_model_profile. - Probe reasoning efforts via the OpenAI-compatible REST endpoint, comparing against the closest neighbour:
POST https://api.x.ai/v1/chat/completionswith{"model":..., "reasoning_effort": <val>, "max_tokens":1}. A rejected value returns 400This model does not support 'reasoning_effort' value '<val>'. Whethernoneis accepted decidesthinking_always_enabled(rejected → always-on). CAVEAT: REST silently acceptsxhigh/minimaleven though the gRPCReasoningEffort(inxai_sdk/types/chat.py) isLiteral['none','low','medium','high']— don't over-read REST acceptance;GrokReasoningEffortis those four and_map_reasoning_effortcollapsesxhigh→high,minimal→low. Grok 4.5 example: acceptslow/medium/high, rejectsnone→ always-on; Grok 4.3 acceptsnonetoo. - Floating aliases (
grok-latest,grok-build-latest) go in the profile reasoning-models set (so passing them resolves the right behavior) but are NOT added asKnownModelNameliterals: the curation rule leaves out-latestaliases. - xai is NOT a gateway provider (
'xai'absent fromproviders/gateway.py'sModelProvider) — nogateway/xai:entries in_known_model_names.py. - Snapshot that ratchets:
tests/test_capability_spec.py::test_model_json_schema_with_capabilitiesembeds the fullKnownModelNameenum. It's a plain sorted string list — hand-add the new ids in sorted position (deterministic, no need for--inline-snapshot=fix). Profile-flag tests go intests/providers/test_xai.py(seetest_xai_model_profile); the parametrizedtests/test_thinking.py::test_grok_43_profile_thinking_supportasserts the 4.3 effort set specifically — don't add a different-effort model to it. - env / probing:
XAI_API_KEYlives in the repo-root.env(not in every worktree). Run probes withsource .env && <script>so$XAI_API_KEYis exported; put anycurlreferencing it in a script file rather than passing the key inline. Verify enumeration/profile logic with a plainuv run pythonsnippet (recurseget_args(XaiModelName), compare toknown_model_names(); callgrok_model_profile(...)directly) rather than a fulluv run pytest tests/run.
Bedrock
- Bedrock Mantle is a separate provider from Bedrock Runtime.
bedrock:(theBedrockProvider, boto3-only) talks to the Converse API;bedrock-mantle:(theBedrockMantleProvider, anopenai-backedProvider[AsyncOpenAI]built onAsyncBedrockOpenAI) talks to Mantle's OpenAI-compatible API. They have separate model catalogs and separate optional extras (bedrockvsbedrock-mantle); don't fold Mantle deps into thebedrockgroup. - Mantle model families use different endpoints, keyed off the profile.
BedrockMantleProvider.model_profilestampsbedrock_mantle_interface: Literal['chat','responses','openai-responses']on the profile (GPT-5.4+ →openai-responsesat/openai/v1; GPT-OSS →responsesat/v1; GPT-OSS Safeguard →chatat/v1).infer_modelreads that (via the profile, not a separate interface method) to pickBedrockMantleResponsesModelvsBedrockMantleChatModel, and the Responses model overridesclientto pick the base URL. Add a family only after verifying its endpoint against the AWS model card + a live request. bedrock:stays on Converse; it does NOT auto-route to Mantle.bedrock_openai_model_profileallows Converse only for the GPT ids it lists; any other proprietary GPT id onbedrock:raises, pointing users tobedrock-mantle:. Add abedrock:GPT id to that allowed set and toLatestBedrockModelNamesonly after a successful Converse call.- Response-scoped tool-call IDs are a profile flag, not a Mantle-wide behavior.
openai_responses_tool_call_ids_are_response_scoped(onOpenAIModelProfile) is enabled only for Mantle GPT-5.6 Responses;OpenAIResponsesModelqualifies call IDs with the response ID in both request and streaming ingestion so history stays uniquely keyed (#6536).
Google (Gemini)
- TWO places for the id, FOUR
KnownModelNameblocks. Add to:LatestGoogleModelNamesinmodels/google.py(GoogleModelName = str | LatestGoogleModelNames— thestrarm is permissive at typecheck time, but the enumeration test only walks theLiteralarm).models/_known_model_names.py— four blocks:gateway/google-cloud:,gateway/google:,google-cloud:,google:(older add-model PRs that only edit three blocks ormodels/__init__.pyare stale; KnownModelName moved in #5803).
- No SDK-lag bridge needed.
google-genaidoes not ship a model-id Literal the enumeration test consumes — the localLatestGoogleModelNamesLiteral is the source of truth. Adding the id lands green immediately. - Profile is substring-gated, with a per-model level table.
profiles/google.py::google_model_profilegates by an older-Gemini negative list (gemini-1,gemini-2.x,gemma): every other id,gemini-4-*included, gets the modern branch (thinking level, tool combination, server-side tool invocations, MIME types in tool returns).'pro' in model_name and 'flash' not in model_namesets always-on thinking. The exception is_MODEL_THINKING_LEVELS, astartswithtable mapping id prefixes to their documented level sets that already holds both pro previews, the 3.7 and 3.8 flash ids, andgemini-3.1-flash-lite-image— so probe every new id rather than assuming the Gemini-3 branch covers it. Probe all four levels withgenerateContentandthinkingConfig.thinkingLevel(MINIMAL,LOW,MEDIUM,HIGH) on the Gemini API and on Vertex separately. A 400 on both means the id needs an entry in the table carrying exactly the levels it accepts (non-contiguous sets likeminimal, highare fine — unsupported unified efforts snap to the nearest documented level). A 400 on only one of them means a level set inGoogleModel.profilegated on the client's transport (_is_google_cloud), asgemini-3.1-flash-imagehas for the Gemini API, so the other API keeps the levels it accepts. Reach Vertex with application-default credentials,GOOGLE_PROJECT, andlocation='global', astests/conftest.py::vertex_providerdoes. If you can probe only the Gemini API and it 400s, use the transport-gated branch too, so Vertex keeps its current behavior. Cite Google's documented level sets in the code comment: the Gemini API thinking table (for image models, the image-generation page instead) and the Vertex thinking table. The probe results decide the entry, even where they diverge from those tables. When neither API can be probed, such as a model with no free tier and no Vertex project, add the entry only where both tables give the same level set, and write "Not probed live" in the comment. Probe too when the release notes claim any other capability divergence (no thinking, image-only, Pro always-on). - API verification:
curl -s "https://generativelanguage.googleapis.com/v1beta/models?pageSize=200&key=$GOOGLE_API_KEY"(key is often in the main worktree.env, not every linked worktree). Confirm exact ids; do not invent dated snapshots or-previewsuffixes. Specialized / limited-access models (e.g. Flash Cyber via CodeMender) are out of scope unless they appear in that public listing. - A Vertex 404 at the default
us-central1does not mean Vertex lacks the id. Probelocation='global'before you conclude the id is Gemini-API-only. - Gateway support is opt-out, not opt-in. The enumeration test generates
gateway/{google,google-cloud}:*for everyLatestGoogleModelNamesentry except those listed inUNSUPPORTED_GATEWAY_MODEL_NAMESintests/models/test_model_names.py. Do not add a new id there; Step 6 covers Gateway support.test_unsupported_gateway_model_names_are_curatedfails on an entry whose id left the curated aliases; remove that entry. - Snapshots / tests: hand-add the new ids in sorted position in
tests/test_capability_spec.py::test_model_json_schema_with_capabilities(plain sorted string list). Mirror-only adds skip new VCR by default; #5527 recorded one forgemini-3.5-flashbut that is not required for a pure name add. - Docs: doc pages name models through the tiered aliases in
docs/model_aliases/aliases.json. Leave pages that pin a model on purpose (docs/models/google.md,docs/capabilities/thinking.md) alone.
Google image-model landmines:
- Direct image generation has a separate public literal,
KnownImageGenerationModelNameinpydantic_ai_slim/pydantic_ai/images/__init__.py. When the task is scoped toImageGenerator, update and test this literal independently; do not automatically widen the change to conversationalKnownModelName, gateway aliases, profiles, and capability snapshots unless those surfaces are explicitly in scope. Client().models.list()returns a lazy pager. Keep the client in a named variable until iteration finishes; constructing it inline can let it be closed before the pager sends its request. The endpoint can still list deprecated preview image IDs, so cross-check the official deprecation page and add only current IDs.- Probe image settings on the exact model and API surface. For
gemini-3.1-flash-image, the minimumgenerateContentvalue isImageConfigDict(image_size='512'); the superficially similar literal'0.5K'is invalid and returns HTTP 400.gemini-3.1-flash-lite-imagesupports only 1K output. Do not transfer value spellings between model families or API examples without a live check.
MoonshotAI (Kimi)
MoonshotAIModelNameinproviders/moonshotai.pyis a local literal, independent of the OpenAI SDK's model enum. Update it andmodels/_known_model_names.pytogether, then refreshtests/test_capability_spec.py::test_model_json_schema_with_capabilities.- The
kimi-k3prefix already coverskimi-k3.1-proandkimi-k3.1-pro-highspeedin both family and provider profiles. Probe before adding another prefix or changing profile flags. - Verify the API at
https://api.moonshot.ai/v1. The separate Kimi Code subscription uses different model IDs. Read the canonical API guide and compare live behavior with the nearest sibling; do not transfer subscription semantics.
Others
Not yet documented here. When you add the next model for one of these providers, add the landmines you encountered to this section before closing the session (see Step 9).
Step 9 — Update this skill
After completing the model-add, before closing the session: if anything came up that isn't already documented in this skill — a new test that ratcheted, a provider-specific dispatch tuple, a misleading SDK behavior, a corrected misconception, an iteration the user had to walk you through — add it to this SKILL.md.
Specifically:
- Provider-specific landmines → the matching subsection (or create it).
- Generic process gaps → the relevant numbered step.
- Workflow shape errors → restructure the steps.
This skill exists to compound learnings. A model-add that surfaced new friction and didn't update this file wasted that friction.
04 同仓库更多 Skills
migrating-agno-to-pydantic-ai
Migrate Python Agno applications to Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `agno` or relies on Agno agents, teams, workflows, sessions, memory, knowledge, tools, hooks, guardrails, approvals, skills, streaming, or AgentOS.
reviewer
Review changes.
pydantic-ai-harness
Extend Pydantic AI agents with capabilities from pydantic-ai-harness -- the Coder coding agent, file and shell tools in local or sandboxed workspaces (Modal, E2B, Render, Sprites, Daytona, boxd, smolvm, BoxLite), Code Mode, sub-agents and planning, memory and skills, context compaction, guardrails and spend limits, web research and browsers, hosted SaaS integrations, step persistence, and background agents on Render Workflows. Use when the user mentions pydantic-ai-harness or pydantic_ai_harness, imports a harness capability such as Coder, CodeMode, FileSystem, Shell, SubAgents, Memory, or ToolGuardrail, or wants a Pydantic AI agent that edits files, runs commands or agent-written Python, delegates, remembers, manages long context, stays within limits, or runs model and tool operations as chained Render task runs.
migrating-deep-agents-to-pydantic-ai-harness
Migrate Python LangChain Deep Agents applications to Pydantic AI and Pydantic AI Harness. Use when the source uses the upstream `deepagents` package or demonstrably reproduces its middleware, backends, skills, memory, subagents, or sandbox contracts. Use `migrating-langchain-to-pydantic-ai` for plain LangChain, LangGraph, or LCEL migrations and `pydantic-ai-harness` for greenfield Harness usage.
migrating-vercel-ai-sdk-and-eve-to-pydantic-ai
Migrate TypeScript Vercel AI SDK or Eve applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `ai`, `@ai-sdk/*`, or `eve`, or relies on `generateText`, `streamText`, `ToolLoopAgent`, `useChat`, Eve agents, tools, skills, subagents, approvals, sessions, channels, schedules, or sandboxes.
migrating-pi-to-pydantic-ai
Migrate TypeScript Pi coding-agent applications, extensions, or packages to Python with Pydantic AI and Pydantic AI Harness. Use when source code imports `@earendil-works/pi-*`, calls `createAgentSession`, registers Pi extensions, or relies on Pi tools, hooks, skills, sessions, compaction, providers, TUI, RPC, or packages.