pydantic_ai.profiles
Bases: TypedDict
Describes how requests to and responses from specific models or families of models need to be constructed and processed to get the best results, independent of the model and provider classes used.
All fields are optional; absent keys mean “use the documented default” (defaults are documented per field below and applied at access sites).
Subclasses (OpenAIModelProfile, AnthropicModelProfile, …) add provider-specific keys; cross-class merging via dict-spread is supported.
Whether the model supports tools. Default: True.
Type: bool
Whether the model supports text output. Default: True.
Type: bool
Whether the model natively supports tool return schemas. Default: False.
When True, the model’s API accepts a structured return schema alongside each tool definition. When False, return schemas are injected as JSON text into tool descriptions as a fallback.
Type: bool
Whether the model supports JSON schema output. Default: False.
This is also referred to as ‘native’ support for structured output.
Relates to the NativeOutput output type.
Type: bool
Whether the model supports a dedicated mode to enforce JSON output, without necessarily sending a schema. Default: False.
E.g. OpenAI’s JSON mode
Relates to the PromptedOutput output type.
Type: bool
Whether the model supports image output. Default: False.
Type: bool
Whether the model supports audio in user messages. Default: False.
Used when converting SpeechParts from realtime session history in
Model.prepare_messages: if True, retained audio is sent to the model as BinaryContent;
otherwise the transcript text is used.
No shipping profile sets this to True yet, so retained realtime audio is currently always
forwarded as transcript text on handoff; enabling it needs per-model-family verification that the
provider accepts audio in user messages.
Type: bool
Whether the model accepts images. Default: True.
The file-input flags (this one, supports_document_input, supports_audio_file_input,
supports_video_input, and the supported_*_media_types sets that narrow each kind to media types)
say which files can be sent to the model. A model adapter turns off what its message mapping cannot
send, whatever the profile says.
A file a tool returns that the model cannot take is replaced, in the request only, by a note naming
it: see Where a returned file is sent. A file in a
user prompt is sent as it is, and the request fails if the model cannot take it.
FileUnderstanding reads the same flags to describe
such files in text instead.
Shipped profiles turn these off where an adapter or a model family is known not to take the file; True
means nothing says otherwise, not that the model was checked. A text-only model served through an adapter
that sends images (a text-only Llama on vLLM, say) needs profile=ModelProfile(supports_image_input=False).
Type: bool
The image media types the model accepts, when it accepts images at all. Default: unset, so images are
judged by supports_image_input alone.
When set, an image of any other media type, such as image/heic, counts as one the model can’t read.
Profiles set it where a provider was seen to reject other types: Anthropic and OpenAI read JPEG, PNG, GIF
and WebP, for example, while Gemini also reads HEIC. See supports_image_input for how the file-input
flags are used.
Whether the model accepts documents, such as PDFs. Default: True.
Which document media types it accepts is narrowed by supported_document_media_types.
See supports_image_input for how the file-input flags are used.
Type: bool
The document media types the model accepts, when it accepts documents at all. Default: every
media type in DocumentMediaType.
Only narrows those known types: a document with any other media type is judged by
supports_document_input alone. Anthropic, for example, reads PDFs and plain text but not Word or
Excel files. See supports_image_input for how the file-input flags are used.
Type: frozenset[DocumentMediaType]
Whether the model accepts audio files, such as an AudioUrl
or audio BinaryContent. Default: True.
Separate from supports_audio_input, which is about realtime speech history. See
supports_image_input for how the file-input flags are used.
Type: bool
The audio media types the model accepts, when it accepts audio files at all. Default: unset, so audio
is judged by supports_audio_file_input alone.
When set, audio of any other media type, such as audio/flac on OpenAI Chat Completions, counts as audio
the model can’t read. See supports_image_input for how the file-input flags are used.
Whether the model accepts video. Default: True.
See supports_image_input for how the file-input flags are used.
Type: bool
The video media types the model accepts, when it accepts video at all. Default: unset, so video is
judged by supports_video_input alone.
When set, video of any other media type counts as video the model can’t read. See supports_image_input
for how the file-input flags are used.
Whether the provider’s API accepts SystemPromptParts inline at any position. Default: False.
When False, non-leading SystemPromptParts are wrapped as UserPromptParts with
<system>...</system> content in Model.prepare_messages. Leading ones still hoist to the
provider’s top-level system parameter, and the system prompt says what the tag means, from the request the
framing_announcement setting says. User prompts and
tool returns go out as written; text in them
that resembles a <system> tag gets a note instead.
APIs that only accept an inline system prompt in certain positions (e.g. Anthropic requires it
to follow a user turn) still set this to True; it’s on their model adapters to make the
positions the API rejects legal. Preserving the part’s authority is worth more than preserving
the exact position it was authored at — an instruction only governs the generation that follows
it, and that’s the same generation either way — so prefer adjusting placement over falling back
to the <system>...</system> rendering, which the model reads as user-authored. Anthropic slides
the entry past intervening user turns and gives it a minimal user turn to follow when nothing
legal precedes it.
Whether the API accepts the role is a fact about the provider, and whether the model gives it system authority
is a fact about the model, so a model profile can set this to False for a host that accepts the role. gpt-oss’s
profile does, on every host: it gives a native mid-conversation system message little more weight than the
user’s own words, so a user message written to look like an application frame can override the application’s
rule, while <system> blocks in a user turn hold on every host measured.
Provider.model_profile is resolved from the model name alone, so when support also turns on
something it can’t see — which SDK client the provider was built with, say — the adapter narrows
this in its own Model.profile override. Narrowing the
flag rather than special-casing the adapter’s own rendering keeps Model.prepare_messages the
only place that knows the <system>...</system> fallback.
Type: bool
Whether the model follows the fallback’s <system> blocks better sealed and after the user’s words. Default: False.
Only meaningful where supports_inline_system_prompts is False. When True, Model.prepare_messages renders
each mid-conversation SystemPromptPart as <system verified>...</system> after the user’s words in
its request, and the announcement at the start of the system prompt says the application’s blocks carry that
attribute and that a block after the user’s words already applies to the reply to them. A user lookalike’s note
in a request with such a block names it. A <system> tag in text from a user, a tool or a file still gets a note
when it copies the attribute.
Set for Claude Sonnet 4.6, Claude Sonnet 5.5, Claude Haiku 5.5, and Grok 4.3 through 4.7 (not Grok 4.20, which
measured worse sealed). Sonnet 4.6, with plain <system> blocks, ignored two mid-conversation instruction
changes, and followed both with a marker and the sentence together (not with either alone). With the blocks
after the user’s words it also followed steering after a tool result and a change next to a user lookalike,
where ahead of them it didn’t. Haiku 5.5 honors a native mid-conversation system message but did as well or
better on every cell measured with this rendering, and worse with plain <system> blocks, so its Anthropic
profile doesn’t use the native role. Sonnet 5.5 credited the native role’s messages to the user when asked who
said what, and with this rendering it attributed them correctly and followed steering after a tool result more
reliably, so its profile doesn’t use the native role either. Those Grok models followed a genuine change next to
a user lookalike and steering after a tool result more reliably sealed than with plain blocks.
Type: bool
The model’s default for the framing_announcement setting. Default: 'when_needed'.
The framing_announcement model setting wins when
it’s set. Only meaningful where supports_inline_system_prompts is False.
'when_needed' sends the same request as 'always' once a conversation has something to explain, and the same
request as 'never' before that. Set to 'always' for Claude Sonnet 4.6 and gpt-oss, which measured worse
without the announcement even on requests with nothing for it to explain: Sonnet 4.6 kept to the system prompt’s
task against a conflicting user request in 30 of 48 runs with it and 22 of 96 without, and followed an
application’s own reminder tags in a user turn in 24 of 24 with it and 0 of 48 without; gpt-oss kept to the
system prompt’s task in 44 of 48 with it and 69 of 96 without. Other models measured did as well or better
without it on those requests. See
When the announcement is sent.
Type: FramingAnnouncement
Whether a tool’s text output is sent as an escaped JSON string field. Default: False.
When True, Model.prepare_messages sends the content of each successful ToolReturnPart whose content is a
string as {"tool_output": "..."}, with the text JSON-escaped, so its newlines and quotes don’t read as plain
lines in the tool message. A string that holds JSON is wrapped the same way, so it’s escaped a second time, which
measured no worse on Qwen3 Next than the JSON as is. Only the outgoing copy changes: the history keeps the tool’s
output as returned. Lookalike notes are still decided on the output as returned.
Set for Qwen3 Next, which treated a tool’s output as information more reliably in this form than as plain text, on every route measured, at a few tokens per tool result and with the cached prefix unchanged.
Type: bool
Whether the provider’s API keeps a request-scoped SystemPromptPart in the conversation and stops rendering it itself. Default: False.
A request-scoped part applies to one model request.
When this is True, the model adapter sends every such part in the history, and the API stops
rendering each one once a later request exists, as Anthropic’s clear_at: 'next_user_message' does.
Sending it unchanged keeps the cached prefix and any reasoning bound to it valid. When False,
Model.prepare_messages leaves a request-scoped part out of every request after its own, and the part
renders like any other mid-conversation SystemPromptPart while it’s current.
Independent of supports_inline_system_prompts: where that’s False, the entry holds a <system> block like the
model’s other mid-conversation messages. Only set it on a model whose adapter renders a self-clearing entry,
currently AnthropicModel. On any other adapter, True makes every request-scoped part render as a lasting
system prompt on every later request.
Type: bool
Whether the provider’s API can change the thinking effort from a point in the conversation onward. Default: False.
When True, on a model whose adapter renders the change (OpenAIResponsesModel’s configuration_update
item, AnthropicModel’s per-message output_config, OpenRouterModel’s configuration_update system
message), a
ModelSettingsDeltaPart is sent in place and the request
keeps the conversation’s earlier request-level effort, so the prompt cache survives the change. When
False, Model.prepare_messages drops those parts and the current effort goes out as the request-level
setting.
Type: bool
The default structured output mode to use for the model. Default: 'tool'.
Type: StructuredOutputMode
The instructions template to use for prompted structured output. The {schema} placeholder will be replaced with the JSON schema for the output. Default: DEFAULT_PROMPTED_OUTPUT_TEMPLATE.
Type: str
Whether to add prompted output template in native structured output mode. Default: False.
Type: bool
The transformer to use to make JSON schemas for tools and structured output compatible with the model. Default: None.
Type: type[JsonSchemaTransformer] | None
Whether prompt caching on this model needs request-side configuration that Pydantic AI can turn on. Default: False.
When True, the unified cache setting
translates into the provider’s caching configuration. When False, it is silently ignored: the model
either doesn’t support prompt caching, or caches implicitly without any request-side opt-in (as
OpenAI’s models before GPT-5.6 and Gemini do), so there is nothing for the setting to turn on.
Set by providers rather than shared profile functions, since cache behavior is a
fact about the provider’s API, not the model family.
Type: bool
Whether the provider has a server-managed automatic prompt-caching mode the request can switch on. Default: False.
The unified cache setting consults it only when supports_cache is True: then, if this is True, the
conversation is cached with that mode, which places and moves the cache breakpoint itself; otherwise the
library places an explicit breakpoint at the end of the conversation too, as it does at the end of the tool
definitions and the static instructions.
On Anthropic, the explicit anthropic_cache setting consults it whatever supports_cache says: if this is
True, the request carries the top-level cache_control parameter; otherwise anthropic_cache falls back
to a breakpoint on the last block.
Type: bool
The prompt-cache retention tiers the request can ask for and the provider honors, shortest first. Default: ().
A retention requested via the unified cache setting snaps down to the nearest supported tier. Empty when
the provider has no retention tier to request, in which case a requested retention caches at the provider’s
default retention (default_cache_retention).
prompt_cache_outlook likewise only lets a
CachePoint.ttl in the history extend the expected retention
when it’s one of these tiers, since a provider that doesn’t support a tier doesn’t honor it on a
cache point either.
Type: tuple[CacheRetention, …]
How long the provider keeps a cached prompt prefix when the request doesn’t ask for a specific retention. Default: None (unknown).
Measured from the last request that used the prefix. Only documented values are populated. When a
provider documents a range, the higher end is used: consumers of a 'cold' outlook are about to pay
for a full prefix re-write, so a false 'cold' sacrifices a live cache hit while a false 'warm'
merely defers maintenance. Because retention is provider infrastructure, providers populate this
field; model-family profile functions must never set it. Providers without an honest documented
expectation boundary leave it None.
Retention requested through model settings, such as anthropic_cache='1h' or
openai_prompt_cache_retention='24h', is resolved by
Model.resolve_cache_retention; this field is
what applies when the settings request nothing.
Consumed by prompt_cache_outlook to classify, from a
message history alone, whether the next request is likely to hit a warm cache. A 'cold' outlook is
a free moment to run history-mutating maintenance (compaction, pruning, repair): the next request
pays a full prefix re-write either way, so the marginal cache cost of the mutation is ~zero.
Type: timedelta | None
Whether the model supports thinking/reasoning configuration. Default: False.
When False, the unified thinking setting in ModelSettings is silently ignored.
Type: bool
Whether the model always uses thinking/reasoning (e.g., OpenAI o-series, DeepSeek R1). Default: False.
When True, the model can’t disable thinking, so thinking=False uses the lowest effort the model accepts instead.
Implies supports_thinking=True.
Type: bool
Whether the model thinks when the request doesn’t configure thinking. Default: False.
True for models that think unless told not to, such as Claude Opus 5, DeepSeek V4 and the OpenAI o-series. Pydantic AI
uses it to tell whether a request without a thinking setting will think, for example to decide whether a
tool call can be forced. Unlike thinking_always_enabled, it doesn’t mean thinking can’t be turned off.
Type: bool
Whether the model accepts a forced tool choice: tool_choice='required' or a specific tool. Default: True.
Some models reject forcing on every request, such as Claude Opus 5.5, Claude Fable 5.1 and 5.2 and Claude
Mythos 5.1 and 5.2, as do some OpenAI-compatible providers, such as Moonshot AI. When False, a forced tool
choice that Pydantic AI resolved itself (such as an output tool’s) falls back to 'auto', with the tools
filtered to the requested ones where the API can’t restrict the choice. An explicit forcing
tool_choice raises a UserError.
Type: bool
Whether the model accepts a forced tool choice while it thinks. Default: True.
DeepSeek’s V4 models, for example, only accept forcing while thinking is off. When False and the request
thinks, a forced tool choice is handled as if supports_forced_tool_choice were False. Whether the request
thinks accounts for thinking_enabled_by_default. On OpenRouter routes other than Anthropic’s, which return a
400 for it, an explicit forcing raises a ModelRequestRejectedError instead of a UserError.
Type: bool
Whether the model answers a forced tool choice without thinking. Default: False.
Claude models accept a forced tool choice alongside adaptive thinking, but return no thinking for that
request. When True and the request thinks, Pydantic AI doesn’t force a tool choice it resolved itself (such
as an output tool’s): it falls back to 'auto', and a structured output_type defaults to
Native Output where the model supports it. An explicit forcing
tool_choice is still sent.
Type: bool
The tags used to indicate thinking parts in the model’s output. Default: DEFAULT_THINKING_TAGS.
Whether this route may encode chat-template special tokens found in message content as real control tokens. Default: False.
Many hosts of open-weight models do, so a literal <|im_start|> in a tool result opens a real turn in the role it
names. When True, Model.prepare_messages puts a zero-width joiner inside each such token in user prompts, tool
results, inlined text files and replayed model output, on the outgoing copy only, and the joiner is removed again
from the tokens in each response’s text and tool call arguments. Text without one is unchanged.
The host decides this, not the model family, so a provider sets it from model_profile, through the one table in
profiles/_special_tokens.py. An application that has pinned a route known to treat these tokens as text, or that
needs them sent as written, can turn it off with profile=.
See Special tokens in content.
Type: bool
Whether the model reproduces markup it finds in prior assistant messages in its own visible output. Default: False.
A model with this quirk reads the assistant turns of the history as examples of how it is supposed to write, so replaying another model’s reasoning as assistant text teaches it to emit those tags in the answers the user reads — and once that answer is persisted, the next turn reinforces it.
When True, a ThinkingPart that can’t be sent through the model’s native reasoning channel is
rendered into a user message ahead of the assistant turn instead of into the turn itself, which
stops the imitation. Attributed to the user, that reasoning would read as something the user thought,
so it is wrapped in an assistant_thinking tag rather than in the model’s own thinking tags. The cost
is that the model reports the reasoning’s authorship inaccurately when asked about it, which naming the
source in the tag would not change.
This is used by AnthropicModel, BedrockConverseModel, OpenAIChatModel (and the models built on it)
and OpenAIResponsesModel, so it also covers Claude served through an OpenAI-compatible provider. An
OpenAIChatModel profile that sends reasoning back in a field (openai_chat_send_back_thinking_parts='field',
as OpenRouter’s does) never renders it as text, so there is nothing for this key to move.
Where the carried reasoning goes is each adapter’s own decision rather than a shared rewrite ahead of
them: it has to land in front of whatever that provider renders next out of the same request — an
Anthropic system entry, for one — which has no message-level existence to insert before.
Type: bool
Whether the model hands work to sub-agents the user didn’t ask for. Default: False.
A sub-agent starts from a fresh context and explores the task again, so unrequested delegation multiplies tool
calls and cost. Instructions that tell a model not to delegate unasked can be sent only to the models with this
key, by reading it from the profile of the model handling the request: see
Instructions for specific models. Pydantic AI Harness Coder does.
Set by openai_model_profile for OpenAI’s GPT models, not gpt-oss or the o-series. Evidence: in a Terminal-Bench
ablation of Coder’s instructions (24 tasks, one trial each, November 2026), GPT-6.1 Terra without its instruction
against unrequested delegation delegated in all 24 tasks (524 delegate_task calls, against none with it), making
about 9 times as many tool calls at about 5.5 times the cost. Claude Sonnet 5.5 didn’t delegate with or without it.
Type: bool
Whether the model explains away inputs that look inconsistent instead of checking whether the task classifies
them (for example as malformed or rejected). Default: False.
Instructions that tell a model to look for such a rule before assuming it misread can be sent only to the models
with this key: see Instructions for specific models. Pydantic AI
Harness Coder does, at 'max' autonomy.
Set by openai_model_profile for OpenAI’s GPT models, not gpt-oss or the o-series, together with
omits_handoff_evidence and ignores_stated_runtime_constraints: the three were measured only together. Evidence:
on Harness-Bench SWE81 with GPT-6.2 Sol at 'max' autonomy, one run each (November 2026), Coder with the three
instructions scored 53.2 against 51.0 without them (measured with the classify sentence in place of the shared
misread check; both are sent here), within that benchmark’s single-run noise of about 5.6 points. So the evidence is
weak, and the instructions are sent only at 'max', where nobody reviews the result before it’s used.
Type: bool
Whether the model’s notes or handoffs leave out the evidence a reviewer needs, such as the verification
commands it ran and their results. Default: False.
Instructions that ask a model for a structured handoff can be sent only to the models with this key: see
Instructions for specific models. Pydantic AI Harness Coder does, at
'max' autonomy.
Set by openai_model_profile for OpenAI’s GPT models, not gpt-oss or the o-series, together with
reinterprets_malformed_inputs: see its docstring for the evidence.
Type: bool
Whether the model ignores constraints a task states on where or how its code will run, such as a restricted
interpreter or a specific Python version, when choosing language features. Default: False.
Instructions that tell a model to find out what’s allowed before writing code can be sent only to the models with
this key: see Instructions for specific models. Pydantic AI Harness
Coder does, at 'max' autonomy.
Set by openai_model_profile for OpenAI’s GPT models, not gpt-oss or the o-series, together with
reinterprets_malformed_inputs: see its docstring for the evidence.
Type: bool
Whether to ignore leading whitespace when streaming a response. Default: False.
This is a workaround for models that emit `<think> </think>
or an empty text part ahead of tool calls (e.g. Ollama + Qwen3), which we don't want to end up treating as a final result when usingrun_streamwithstra validoutput_type`.
This is currently only used by OpenAIChatModel, HuggingFaceModel, GroqModel, and BedrockConverseModel.
Type: bool
The set of native tool types that this model/profile supports. Default: SUPPORTED_NATIVE_TOOLS (all).
Type: frozenset[type[AbstractNativeTool]]
The maximum number of tokens the model can handle in a single request, input and output combined. Default: None (unknown).
When no profile layer sets this, Model.profile fills it in from
genai-prices data if the model is known there.
Set it explicitly for custom or local models, e.g. profile={'context_window': 128_000}.
Whether the model can compact a conversation when asked, with Model.compact_messages. Default: False.
NativeCompaction compacts only for a model with it. It’s set for the
OpenAI Responses API on OpenAI and Azure OpenAI, and for the Claude models Anthropic’s Messages API compacts
on demand: see Anthropic’s on-demand compaction docs
for the models.
Type: bool
How the model’s on-demand compaction takes instructions, such as a focus for the summary. Default: None (it takes none).
'replaces_prompt': the instructions replace the provider’s summarization prompt, so a focus is sent inside a full summarization prompt. Anthropic works this way.'system_prompt': the instructions are the system prompt of the compaction request, in place of the agent’s, so the request no longer starts with the prefix the provider cached for the conversation. OpenAI works this way.
Type: CompactionInstructionsMode | None
The provider’s deprecation of this model on the API the model class sends requests to. Default: None.
When set, each request to the model emits a DeprecatedModelWarning.
Set by AnthropicProvider and
OpenAIProvider from the providers’ deprecation pages, except
where the model is served by another platform with a schedule of its own: the Amazon Bedrock and Google Cloud
Vertex AI clients of AnthropicModel, the Azure client of the OpenAI models, and the Codex backend. Set by
GoogleModel and
GoogleInteractionsModel from the Gemini API’s or
Google Cloud’s deprecation page, whichever its client reaches. Set it to None to stop the warning for one model, or to a ModelDeprecation of
your own for a model you serve elsewhere.
See Deprecated models.
Type: ModelDeprecation | None
The exact length of the ASCII-alphanumeric tool call IDs the model accepts. Default: None (any ID).
Some models only accept tool call IDs of exactly this many a-z, A-Z and 0-9 characters, and reject
a history whose IDs came from another provider (OpenAI’s call_..., Anthropic’s toolu_...) or were
generated by Pydantic AI (pyd_ai_...). When set, Model.prepare_messages replaces every function tool
call ID that doesn’t fit with a hash of it that does, and leaves IDs that already fit unchanged. The
calls, their results and the <pyai:tool_result> tags that reference them keep pairing up, and since the
replacement depends only on the history, the same history is sent as the same bytes on every request.
Only the outgoing copy changes: stored message history keeps the original IDs.
Whether the model’s tool call IDs are only unique within one response. Default: False.
Pydantic AI pairs each tool call with its result by tool_call_id across the whole message history, so an API
that numbers the calls in every response from scratch (call_0, then call_0 again in the next response) makes
two different calls look like one. When set, each tool call ID the provider sends is stored with a suffix derived
from its response’s provider_response_id, or from its
timestamp when it has none, such as call_0_k3ZcR9aQ. The suffix
is the same every time the response is replayed, and keeps the ID within the [a-zA-Z0-9_-] characters that
Anthropic and Bedrock require. IDs Pydantic AI generates itself are already unique and are left alone, and so
is a call an OpenAIResponsesModel stream receives before the response’s ID, which a request continuing that
response with previous_response_id couldn’t restore from the timestamp.
When the history is sent back to the same provider and endpoint, the suffix is removed again, so the provider gets the IDs it sent. Other providers and endpoints get the stored IDs.
Supported by OpenAIChatModel and
OpenAIResponsesModel, and set by the
Bedrock Mantle provider for the GPT-5 models it serves on the Responses API.
Type: bool
Whether the API rejects a tool call that has no result, or a tool result that names no call. Default: False.
When set, Model.prepare_messages pairs the history it translates from another provider’s native tool search: a
translated search_tools result whose ID names no call takes the ID of the oldest call in its response still
waiting for one, and a translated call that has no result gets a synthesized interrupted result. It doesn’t touch
other unanswered tool calls, which the repair every agent run makes already handles. Set by
OpenAIProvider, and by
AnthropicModel for the AsyncAnthropic client. See
Configuring ToolSearch.
Type: bool
When the provider permits a tools entry whose schema is withheld. Default: None.
'standalone' permits the deferral flag on its own. 'with_tool_search' permits it only when a
tool-search tool is present in the same request. None means hidden tools can only be withheld
from the wire. Unsupported deferral is handled on a best-effort basis by withholding the tool.
Type: ToolDeferralMode | None
How the model natively expresses tools added mid-conversation. Default: None.
'by_reference' reveals a tool already declared in the request’s tool definitions (Anthropic
tool_addition blocks referencing a defer_loading entry); 'with_definitions' carries the full
newly available definitions in the reveal (OpenAI Responses additional_tools items). None means
no native channel: Model.prepare_messages projects the change into messages. Additions only —
tool removal (#6985) is not modeled yet and will get its own field.
Type: ToolAdditionMode | None
Deprecated: use tool_addition_mode instead.
Translated (with a deprecation warning) whenever profiles are merged; an explicit
tool_addition_mode in the same profile wins.
Type: ToolAdditionMode | None
Deprecated: use tool_deferral_mode instead.
True translates to tool_deferral_mode='with_tool_search' (with a deprecation warning)
whenever profiles are merged. False carried no signal on its own — deferral capability came
from native tool-search support — so it is dropped; an explicit tool_deferral_mode in the
same profile wins.
Type: bool
A provider’s announced deprecation of a model on its API.
Set as a model’s deprecation, it makes each request to the
model emit a DeprecatedModelWarning.
The provider’s announcement of the deprecation.
Type: str
The date the provider stops serving the model, or None if it hasn’t announced one.
Type: date | None Default: None
The model the provider recommends instead, or None if it names none.
Type: str | None Default: None
The model the provider answers this model’s requests with from retirement_date, or None if they fail then.
Type: str | None Default: None
Bases: ABC
Walks a JSON schema, applying transformations to it at each level.
The transformer is called during a model’s prepare_request() step to build the JSON schema before it is sent to the model provider.
Note: We may eventually want to rework tools to build the JSON schema from the type directly, using a subclass of pydantic.json_schema.GenerateJsonSchema, rather than making use of this machinery.
The strict parameter forces the conversion of the original JSON schema (self.schema) of a ToolDefinition or OutputObjectDefinition to a format supported by the model provider.
The “strict mode” offered by model providers ensures that the model’s output adheres closely to the defined schema. However, not all model providers offer it, and their support for various schema features may differ. For example, a model provider’s required schema may not support certain validation constraints like minLength or pattern.
Default: strict
Whether the schema is compatible with strict mode.
This value is used to set ToolDefinition.strict or OutputObjectDefinition.strict when their values are None.
Default: True
@abstractmethod
def transform(schema: JsonSchema) -> JsonSchema
Make changes to the schema.
JsonSchema
Bases: JsonSchemaTransformer
Transforms the JSON Schema to inline $defs, and $refs that point elsewhere in the schema like #/properties/from.
Object keywords (properties, additionalProperties, patternProperties, propertyNames) are only walked
when type is 'object', and array keywords (items, prefixItems, contains) only when it is 'array'.
On a schema with no type, or with a type list such as ['object', 'null'], they are left as written,
so a $ref inside them is not inlined and can point at a definition the output no longer contains.
If the schema is only meant to accept objects (or arrays), set type to 'object' (or 'array') to have
it inlined; for a nullable one, put it in an anyOf with {'type': 'null'} instead of using a type list.
Keywords that apply to every type, such as not, if/then/else, dependentSchemas and
unevaluatedProperties, aren’t walked, so transform() doesn’t run under them. A $ref there is replaced by its
definition as written, and one that leads back into its own definition stays, with the definition kept under
$defs.
def merge_profile(
base: ModelProfile | None,
*overrides: ModelProfile | None,
) -> ModelProfile
Merge profiles via dict-spread. Later arguments override earlier ones; None is treated as empty.
This is the canonical way to layer profiles in providers and tests; replaces the old ModelProfile.update() method.
Deprecated key spellings are translated per input before spreading, so a legacy key in an
override still overrides the base.
def prompt_cache_outlook(
messages: Sequence[ModelMessage],
*,
profile: ModelProfile | None = None,
retention: timedelta | None = None,
now: datetime | None = None,
) -> PromptCacheOutlook
Predict whether the provider’s prompt cache is still warm for the next request on this history.
This is a pure function of the message history and an expectation boundary — it holds no state and makes no
requests, so a history processor, capability, or plain application code can call it with just a
message history to decide whether the next turn is a cheap moment for history-mutating maintenance
(compaction, pruning, repair). When the outlook is 'cold' the next request pays a full prefix
re-write anyway, so the marginal cache cost of mutating history right now is ~zero.
The prediction compares the most recent ModelResponse.timestamp
in messages against now: an idle gap within the retention window is 'warm', a larger gap is 'cold'.
Responses are the anchor because they mark the provider’s last confirmed use of the cache — a request that
has no response after it (like the just-appended request a history processor
sees, which hasn’t been sent yet) never touched the cache, so its timestamp must not reset the idle clock.
Cache points in the history extend whichever boundary applies to their largest TTL that the provider
honors: on a profile with supports_cache, one of its
supported_cache_retentions. Without a profile,
or with one that doesn’t describe its cache configuration, every cache point TTL is assumed to be honored.
PromptCacheOutlook — 'warm', 'cold', or 'unknown' (see PromptCacheOutlook).
messages : Sequence[ModelMessage]
The message history the next request would be built on, oldest first.
profile : ModelProfile | None Default: None
The model profile whose default_cache_retention
is used as the expectation boundary when retention is None.
retention : timedelta | None Default: None
The retention requested for these requests, replacing the profile’s default. With a model
and its settings in hand, pass
model.resolve_cache_retention(model_settings):
it returns None when the settings request nothing, so the profile’s default still applies.
The reference time to measure idleness against. Defaults to the current UTC time; inject a fixed value for deterministic tests.
Acceptable shapes for the profile= argument on a Model.
- A
ModelProfiledict — a partial profile, merged on top of the provider’s resolved default. - A
Callable[[ModelProfile], ModelProfile]— receives the provider’s resolved default (withDEFAULT_PROFILEalready merged in) and returns the final profile (full control: replace, derive, ignore the default).
Provider classes still expose Provider.model_profile(model_name) (Callable[[str], ModelProfile | None]) — that’s a separate concept used internally by Model.profile to resolve the provider’s default for a given model name.
Type: TypeAlias Default: ModelProfile | Callable[['ModelProfile'], 'ModelProfile']
Predicted state of the provider’s prompt cache for the next request built on a message history.
'warm': the last request happened within the provider’s documented expectation boundary, so the cached prefix is likely still available and the next request should hit it.'cold': the last request happened longer ago than the retention window, so the prefix has likely been evicted and the next request will pay full input price regardless — a free moment to mutate history.'unknown': there’s no retention figure for the model, or the history has no usable timestamp, so no prediction can be made. Treat like'warm'for scheduling (never mutate on a guess).
Type: TypeAlias Default: Literal['warm', 'cold', 'unknown']
Default ModelProfile, with a value for every key except the image, audio and video media-type sets, which are
unset unless a profile knows them. Used as the base layer when resolving a model’s effective profile.
Type: ModelProfile Default: {'supports_tools': True, 'supports_text_output': True, 'supports_tool_return_schema': False, 'supports_json_schema_output': False, 'supports_json_object_output': False, 'supports_image_output': False, 'supports_audio_input': False, 'supports_image_input': True, 'supports_document_input': True, 'supported_document_media_types': KNOWN_DOCUMENT_MEDIA_TYPES, 'supports_audio_file_input': True, 'supports_video_input': True, 'default_structured_output_mode': 'tool', 'prompted_output_template': DEFAULT_PROMPTED_OUTPUT_TEMPLATE, 'native_output_requires_schema_in_instructions': False, 'json_schema_transformer': None, 'supports_cache': False, 'supports_auto_cache': False, 'supported_cache_retentions': (), 'default_cache_retention': None, 'supports_thinking': False, 'thinking_always_enabled': False, 'thinking_enabled_by_default': False, 'supports_forced_tool_choice': True, 'supports_forced_tool_choice_with_thinking': True, 'forced_tool_choice_disables_thinking': False, 'thinking_tags': DEFAULT_THINKING_TAGS, 'may_tokenize_special_tokens_in_content': False, 'mimics_assistant_message_formatting': False, 'ignore_streamed_leading_whitespace': False, 'supported_native_tools': SUPPORTED_NATIVE_TOOLS, 'context_window': None, 'supports_compaction_on_demand': False, 'compaction_instructions': None, 'tool_call_id_length': None, 'tool_call_ids_are_response_scoped': False, 'tool_deferral_mode': None, 'tool_addition_mode': None}
Default instructions template for prompted structured output. The {schema} placeholder is replaced with the JSON schema for the output.
Default: dedent("\n Always respond with a JSON object that's compatible with this schema:\n\n {schema}\n\n Don't include any text or Markdown fencing before or after.\n ")
Default (start_tag, end_tag) pair for parsing thinking content out of text responses.
Type: tuple[str, str] Default: ('<think>', '</think>')
Bases: ModelProfile
Profile for models used with OpenAIChatModel.
ALL FIELDS MUST BE openai_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Non-standard field name used by some providers for model thinking content in Chat Completions API responses. Default: None.
Plenty of providers use custom field names for thinking content. Ollama and newer versions of vLLM use reasoning,
while DeepSeek, older vLLM and some others use reasoning_content.
Notice that the thinking field configured here is currently limited to str type content.
If openai_chat_send_back_thinking_parts is set to 'field', this field must be set to a non-None value.
Whether the model includes thinking content in requests. Default: 'auto'.
This can be:
'auto'(default): Automatically detects how to send thinking content. Thinking received from this provider (tracked viaThinkingPart.provider_name) is sent back in a field only when itsThinkingPart.idis the configuredopenai_chat_thinking_field, or, with none configured,reasoningorreasoning_content, the fields checked by default when receiving responses. Any other thinking is sent using tags, including thinking received in a field this profile doesn’t name, such as history from another model on the same provider. If your provider uses a different field name, you must explicitly setopenai_chat_thinking_fieldto that field name. When the request sends exactly one of these fields back, it’s also sent empty on tool-calling assistant turns after the last user message that don’t already carry it, such as a step served by another model or provider, since DeepSeek-style APIs reject those turns without it.'tags': The thinking content is included in the maincontentfield, enclosed within thinking tags as specified inthinking_tagsprofile option.'field': The thinking content is included in a separate field specified byopenai_chat_thinking_field.False: No thinking content is sent in the request.
Thinking sent as text in 'auto' or 'tags' mode goes in a user message ahead of the assistant message
instead when the profile sets
mimics_assistant_message_formatting.
Defaults to 'auto' to ensure thinking is sent back in the format expected by the model/provider.
Type: Literal[‘auto’, ‘tags’, ‘field’, False]
Whether the API rejects a thinking request whose tool-calling assistant turn lacks openai_chat_thinking_field. Default: False.
Only applies when openai_chat_send_back_thinking_parts is 'field'. In that mode, a tool-calling assistant
turn that lacks the field gets it empty from the first response in the history that holds a ThinkingPart on;
an earlier turn was already sent without it, so it keeps going out that way. Set this for an API that also
rejects such a turn before any response has thought, such as a step served without thinking: the field is then
sent empty on every such turn whenever thinking is on for the request, through a setting or
thinking_enabled_by_default.
Type: bool
This can be set by a provider or user if the OpenAI-”compatible” API doesn’t support strict tool definitions. Default: True.
Type: bool
A list of model settings that are not supported by this model. Default: ().
Deprecated: use supports_forced_tool_choice instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
Deprecated: use supports_forced_tool_choice_with_thinking instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
The role to use for the system prompt message. If not provided, defaults to 'system'.
Type: OpenAISystemPromptRole | None
Whether the Chat Completions API accepts more than one system-role message at the start of the conversation. Default: True.
OpenAI itself and most compatible providers accept multiple system messages, so this defaults to True.
Set to False for strict OpenAI-compatible backends (e.g. some LiteLLM/vLLM deployments) that require
exactly one initial system message; consecutive system messages at the start will be merged into one
(joined with two newlines) before being sent.
Type: bool
Whether a streamed Chat Completions response must include a non-null finish_reason. Default: False.
When enabled, reaching clean EOF before any chunk supplies a finish_reason raises
ModelConnectionError with phase='read', as a stream that was
cut off, instead of treating the response as a 'stop'.
This defaults to False because OpenAI-compatible APIs do not consistently guarantee the field.
Type: bool
Whether every streamed Chat Completions chunk repeats the running usage totals unprompted. Default: False.
When enabled, each chunk’s usage replaces the usage recorded so far instead of adding to it, as
openai_continuous_usage_stats
does, without sending stream_options.continuous_usage_stats.
OpenAIProvider enables it for gemini* model names, including
through a custom base_url. A server that serves these names and reports per-chunk deltas instead would have its
usage under-reported, so turn this off in the model’s profile.
CloudflareProvider enables it because Workers AI ends a
stream with the totals of the per-chunk counts before them. A stream that stops early reports only its last count.
Type: bool
Whether Chat Completions usage leaves reasoning tokens out of completion_tokens and counts them only in total_tokens. Default: False.
When enabled and usage carries no completion_tokens_details, the amount by which total_tokens exceeds
prompt_tokens + completion_tokens counts as output and reasoning tokens, in each streamed chunk too.
OpenAIProvider enables it for gemini* model names, including
through a custom base_url. A server that serves these names and counts anything else in that gap would have its
output tokens over-reported, so turn this off in the model’s profile.
Type: bool
Whether the model supports web search in Chat Completions API. Default: False.
Type: bool
Whether a Chat Completions url_citation annotation’s offsets span the cited text. Default: False.
The Chat Completions counterpart of
openai_responses_url_citation_content_offsets.
Type: bool
The encoding to use for audio input in Chat Completions requests. Default: 'base64'.
'base64': Raw base64 encoded string. (Default, used by OpenAI)'uri': Data URI (e.g.data:audio/wav;base64,...).
Type: Literal[‘base64’, ‘uri’]
Whether the Chat API supports file URLs directly in the file_data field. Default: False.
OpenAI’s native Chat API only supports base64-encoded data, but some providers like OpenRouter support passing URLs directly.
Type: bool
Whether the model supports including encrypted reasoning content in the response. Default: False.
Type: bool
Whether the model supports reasoning (o-series, GPT-5+). Default: False.
When True, sampling parameters may need to be dropped depending on reasoning_effort setting.
Type: bool
Deprecated: use thinking_enabled_by_default instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
Whether the model accepts reasoning_effort='none' and allows sampling parameters (temperature, top_p, etc.)
while reasoning is off. Default: False.
The GPT-5.1+ mainline models support turning reasoning off via effort='none', and sampling params are
accepted in that mode. When reasoning is enabled (low/medium/high/xhigh), sampling params are not supported.
Whether the model reasons by default is tracked separately by thinking_enabled_by_default.
Ignored when openai_reasoning_efforts is set: 'none' in that set decides it instead.
Type: bool
Whether the model accepts reasoning_effort='minimal'. Default: True.
Disabled for GPT-5.6 models, whose documented reasoning efforts exclude minimal. When disabled,
unified thinking='minimal' falls back to reasoning_effort='low'.
See https://developers.openai.com/api/docs/guides/latest-model.
Explicit openai_reasoning_effort='minimal' settings are still passed through unchanged.
OpenAIProvider also disables it for the GPT-5.1 through GPT-5.5 families, which OpenAI’s API answers with a 400
for minimal (verified live on gpt-5.1, gpt-5.2, gpt-5.3-codex, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.5
and their dated snapshots). gpt-5.5-cyber-preview and gpt-5.3-codex-spark are covered by the prefix only. The
-pro and -chat variants set openai_reasoning_efforts, which decides instead; the other ids under these
prefixes return 404 (shut down or nonexistent). openai_model_profile leaves it on,
because OpenRouter accepts minimal for these models. OpenAIProvider(base_url=...) keeps the flag off, as a
proxy to OpenAI should; for another server that serves these model names and accepts minimal, pass
profile=OpenAIModelProfile(openai_supports_minimal_reasoning_effort=True).
Ignored when openai_reasoning_efforts is set.
Type: bool
The reasoning_effort values the model accepts. Default: unset.
When set, the unified thinking setting resolves to the
closest accepted effort: the lowest one at or above the requested level, else the highest. thinking=False
sends 'none' where it’s accepted, and otherwise the lowest accepted effort, so a model that always
reasons (thinking_always_enabled) thinks as little as it can. An empty set means the model has no
effort knob, so the unified setting sends nothing.
When set, it also decides whether the model takes 'none' and 'minimal', in place of
openai_supports_reasoning_effort_none and openai_supports_minimal_reasoning_effort. When unset, unified
levels map one-to-one (see openai_supports_minimal_reasoning_effort), and thinking=False sends nothing on a
model that always reasons.
Explicit openai_reasoning_effort settings are passed through unchanged.
OpenAIProvider sets an empty set for gpt-5-search-api, which OpenAI’s API answers with a 400 for any
reasoning_effort (verified live, 2026-11). openai_model_profile keeps the 'gpt-5' efforts, as the
restriction is unverified on the OpenAI-compatible endpoints that share it. OpenAIProvider(base_url=...) keeps
the empty set, as a proxy to OpenAI should; for another server that serves this model name and accepts an effort,
pass profile=OpenAIModelProfile(openai_reasoning_efforts=...) with the efforts it accepts.
Type: frozenset[OpenAIReasoningEffort]
Whether the Chat Completions API accepts reasoning_effort='max' for this model. Default: False.
When enabled, unified thinking='max' is sent as reasoning_effort='max'; otherwise it falls back to 'xhigh'.
OpenAI’s own Chat Completions API rejects 'max' on every model, so only providers that accept it set this
(DeepSeek V4, and Kimi K3, K2.6 and K2.7). Explicit openai_reasoning_effort='max' settings are still passed through unchanged.
Type: bool
Whether the Chat Completions API rejects function tools while reasoning is on. Default: False.
When enabled, OpenAIChatModel raises a ModelRequestRejectedError for a request that sends tools, output tools
included, with reasoning on, before anything is sent: the API rejects the combination with a 400 pointing at
/v1/responses or reasoning_effort='none'. OpenAIProvider enables it for the GPT-5.4, GPT-5.6 and GPT-6
families (verified live on gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.6, gpt-5.6-sol, gpt-5.6-luna,
gpt-5.6-terra, gpt-6-luna, gpt-6-sol, gpt-6.1-terra, gpt-6-astra, gpt-6.1-sol, gpt-6.2-sol and gpt-6.2-astra).
GPT-5.4 reasons only when asked, so its tool requests are rejected only with reasoning turned on.
openai_model_profile leaves it off, because the restriction is unverified on the OpenAI-compatible endpoints
that share that profile.
OpenAIProvider(base_url=...) keeps the flag, as a proxy to OpenAI should; for another server that serves
these model names, pass profile=OpenAIModelProfile(openai_chat_function_tools_require_reasoning_off=False).
On models that pin openai_reasoning_efforts (e.g. gpt-6-astra), thinking=False maps to the lowest
accepted effort rather than 'none', so it is not a way out there.
Type: bool
Request body fields that unified thinking=False sends on the Chat Completions API, in place of
reasoning_effort. Default: unset.
For providers whose off switch isn’t reasoning_effort='none', or whose lowest effort on a model that always
reasons isn’t known from openai_reasoning_efforts. MoonshotAIProvider sets it to
{'thinking': {'type': 'disabled'}} on Kimi K2.5 and K2.6, and to {'reasoning_effort': 'low'} on Kimi K3,
which always reasons. The fields go out through extra_body, where keys the caller set in extra_body win,
and nothing is added when openai_reasoning_effort is set explicitly.
Request body fields that unified thinking_summary=False sends on the Chat Completions API, to ask it not to
return the model’s thinking. Default: unset.
Unset for an API with no such switch, where thinking_summary=False is ignored. Set by OpenAI-compatible
providers that have one, such as vLLM ({'include_reasoning': False}). The fields go out through extra_body,
where keys the caller set in extra_body win.
Whether the Responses API accepts reasoning.effort='max' for this model. Default: False.
OpenAIProvider enables it for the GPT-5.6 and GPT-6 families. openai_model_profile leaves it off, because
max is unverified on the OpenAI-compatible endpoints that share that profile, and so do the Codex and ChatGPT
plan usage profiles. When enabled, unified thinking='max' is sent as reasoning.effort='max'; otherwise it
falls back to 'xhigh'. Explicit openai_reasoning_effort='max' settings are still passed through unchanged.
Type: bool
Whether the Responses API supports reasoning.mode ('standard' | 'pro') for this model. Default: False.
Currently only supported by the GPT-5.6 family.
Type: bool
Whether the Responses API accepts reasoning.context='all_turns' for this model. Default: False.
auto and current_turn are accepted by every reasoning model, so they are gated on
openai_supports_reasoning instead; only all_turns requires this flag.
Currently supported by the GPT-5.4, GPT-5.5, and GPT-5.6 families.
Type: bool
Whether the Responses API requires the status field on function tool calls to be None. Default: False.
This is required by vLLM Responses API versions before https://github.com/vllm-project/vllm/pull/26706. See https://github.com/pydantic/pydantic-ai/issues/3245 for more details.
Type: bool
Whether the Responses API accepts text.format of type json_schema for this model. Default: False.
Only needed when the Responses API is more capable than Chat Completions for the same model, as with
DeepSeek, whose Chat Completions endpoint rejects response_format of type json_schema with
This response_format type is unavailable now while its Responses endpoint honors the schema. When set,
OpenAIResponsesModel enables supports_json_schema_output on its resolved profile, so
NativeOutput becomes available on the Responses API alone.
Type: bool
Deprecated: use tool_call_ids_are_response_scoped instead.
Translated (with a deprecation warning) whenever profiles are merged; an explicit
tool_call_ids_are_response_scoped in the same profile wins.
Type: bool
Whether a Responses url_citation annotation’s offsets span the cited text. Default: False.
OpenAI’s offsets span the citation marker the model wrote, such as a Markdown link, so they map to a
MarkerCitationAnchor. With True, they map to a
ContentCitationAnchor, as DeepSeek’s do.
Type: bool
Whether the Responses API accepts function calls interleaved with other assistant items in one
assistant turn. Default: True.
DeepSeek’s Responses endpoint merges each
function call into the assistant message next to it, so an assistant item between two calls
splits them into separate messages that each carry an unanswered call
(#7430). When this is False, such a turn
has its calls moved to the end before the request goes out; the message history you hold is
unchanged.
Reordering is best-effort: a turn carrying a native or compaction item, or a call still waiting on its result, is sent in its original order.
Type: bool
Whether the Responses API supports the phase field on assistant messages. Default: False.
phase labels an assistant message as intermediate commentary or the final_answer. When the model
supports it, OpenAI recommends preserving and sending it back unchanged on every assistant message in
follow-up requests; dropping it can cause preambles to be interpreted as final answers and degrade
behavior in long-running or tool-heavy flows.
Supported by gpt-5.3-codex, gpt-5.4 and later mainline models. The official OpenAI Responses API
silently ignores the field on older models, but defaults to False so we don’t risk sending an
unrecognized field to OpenAI-compatible APIs (vLLM, Bifrost, …) that haven’t been verified to accept it.
Type: bool
Whether the Chat Completions API supports document content parts (type='file'). Default: True.
Some OpenAI-compatible providers (e.g. Azure) do not support document input via the Chat Completions API.
Type: bool
Whether the Chat Completions API accepts the max_completion_tokens field for the max_tokens setting. Default: True.
OpenAI itself (including the o-series reasoning models) uses max_completion_tokens, the field that caps
visible output plus reasoning tokens, so this defaults to True. Many OpenAI-compatible providers (e.g.
OpenRouter) only accept the older max_tokens field; set this to False for those so the max_tokens
setting is sent as max_tokens instead.
Type: bool
Whether the Chat Completions API accepts an allowed_tools tool_choice. Default: False.
When True, a tool_choice that restricts the model to a
subset of tools is sent as allowed_tools, keeping the full tools array (and so the prompt cache) intact.
When False, the tools array is filtered down to the subset instead. Set by OpenAIProvider, including when
its base_url points at an OpenAI-compatible server. Set it to False in the model’s profile for a server that
rejects or ignores allowed_tools, as OpenRouter and xAI do (their own providers leave it off).
Type: bool
Whether the model supports OpenAI explicit prompt cache breakpoints. Default: False.
When enabled, CachePoint markers are translated into
prompt_cache_breakpoint fields on the preceding content block, on both the Chat Completions and
Responses APIs. When disabled, CachePoint markers are filtered out.
Type: bool
Whether the Responses API gets the instructions that keep the prompt prefix stable as leading input messages.
Default: False.
Those are the literal instructions and the on_change='append'
blocks, whose changes are appended to the history. The instructions that rewrite the prefix when they change stay
in the top-level instructions field, and with
openai_cache_instructions
too. All of them stay there on a request that sets a concrete openai_previous_response_id or
openai_conversation_id, continues a compacted history, has a dynamic system prompt, or uses the 'user' system
prompt role. With openai_previous_response_id='auto' (which openai_transport='websocket' sets by default), they
lead the input when the chain starts or resends the history, and are left out while it continues: each response’s
history digest records them, so a request with different ones resends the history.
Set by OpenAIProvider for gpt-6.2-sol and gpt-6.2-astra, which put the top-level instructions after
input and bill them at the uncached rate on every request:
https://developers.openai.com/api/docs/guides/prompt-caching#how-prefix-matching-works.
Type: bool
Whether the Responses API accepts a tool_choice naming a tool that only an additional_tools input item
declares. Default: False.
Set by OpenAIProvider for GPT-5.6 and later models, which accept it by name and in allowed_tools. Earlier
models reject it with Tool choice '<name>' not found in 'tools' parameter., so when a request’s tool_choice
names a tool revealed that way, OpenAIResponsesModel declares it in tools for that request instead, which
changes that request’s cached prompt prefix. A request with openai_previous_response_id or
openai_conversation_id set keeps the tool in the item alone, so earlier models still reject it: declaring it in
tools would leave the item out of the stored response and hide the tool from every request that continues it.
Type: bool
Whether the Responses endpoint serves prompt cache diagnostics for this model. Default: False.
When True, requests pass the most recent response from the same provider as
prompt_cache_options.comparison_response_id, unless the
openai_prompt_cache_diagnostics
setting is False. Set by OpenAIProvider for GPT-5.6 and later models; OpenAI-compatible Responses
endpoints may reject the field (OpenRouter does), so it stays off for them.
Type: bool
Whether the model can send Responses requests over a WebSocket. Default: True.
When False, openai_transport='websocket'
warns with an UnsupportedSettingWarning and sends each request
over HTTP. Set by AzureProvider, and by OpenAIResponsesModel for an AsyncAzureOpenAI client and the
Pydantic AI Gateway; a True in the model’s profile= wins over these. It stays False whatever profile= says
for providers that add OAuth credentials to HTTP requests only (openai-chatgpt, openai-codex),
and OpenAICodexModel, whose HTTP authentication or session headers cannot configure the SDK socket client.
Per-request credentials are a runtime fallback instead: API key callbacks, workload identities, Azure AD token
providers and HTTP client authentication use HTTP regardless of this capability flag.
Type: bool
Whether the Responses WebSocket endpoint runs concurrent responses on separate stream_id lanes.
When True, concurrent requests that
openai_transport='websocket' sends
over the model’s socket each run on their own named stream_id lane. When False, requests send no stream_id
and the socket runs one at a time, sending the others over HTTP, since an endpoint that doesn’t route events by
stream_id would hand one request another’s events. When unset, the socket decides by the host of the SDK
client’s WebSocket URL when it opens: lanes on api.openai.com, one at a time on any other host, including
services and proxies reached through OpenAIProvider. An explicit value wins, set either in the model’s
profile= or in a provider subclass’s model_profile.
Type: bool
Whether the Responses endpoint serves streaming responses only. Default: False.
When True, nominally non-streaming requests are sent with stream=True and aggregated from the
terminal response.completed event, so callers see an ordinary non-streaming ModelResponse.
Set for subscription-auth endpoints (e.g. OpenAI Codex) that reject stream=False.
Type: bool
Whether the Responses endpoint requires store=false on every request. Default: False.
When True, store=false is sent even when no openai_store setting is given (the field cannot be
omitted), and an explicit openai_store=True setting is silently overridden, consistent with how
other backend-rejected settings are dropped.
Type: bool
Whether the Responses API rejects a reasoning item whose stream was cut off before the item finished.
Default: False.
When enabled, OpenAIResponsesModel sends the part of the reasoning summary it received as text in the model’s
thinking tags instead of as a reasoning item, unless storage is off for the request, or the response was created
in background mode or over a WebSocket. In testing, OpenAI answered a request that sent such an item from a
response that was created with storage on (the default) with a 404 (Item with id 'rs_…' not found), and accepted
it from a response created with openai_store=False. OpenAIProvider enables it, and OpenAIResponsesModel turns
it off for an Azure OpenAI client. openai_model_profile leaves it off, because the behavior is unverified on the
OpenAI-compatible endpoints that share that profile. OpenAIProvider(base_url=...) keeps the flag, as a proxy to
OpenAI should; for another server that accepts the item, pass
profile=OpenAIModelProfile(openai_responses_rejects_cut_off_reasoning=False).
Type: bool
Whether the provider exposes server-side input-token counting (responses/input_tokens). Default: True.
When False, count_tokens() raises a UserError that is also a NotImplementedError instead of calling a
missing endpoint.
Type: bool
Whether the provider serves the OpenAI Batch API for Responses API
requests. Default: False.
BatchModelRequests and
model_request_batch use it with OpenAIResponsesModel, which uploads a
batch’s requests with POST /v1/files and submits them with POST /v1/batches for the /v1/responses endpoint.
Set by OpenAIProvider, also for an OpenAI-compatible base_url, except with an Azure OpenAI client, whose
batches need a batch deployment. Set it in a custom profile for another provider that serves these endpoints, or
to False for an endpoint that doesn’t.
Type: bool
Bases: JsonSchemaTransformer
Recursively handle the schema to make it compatible with OpenAI strict mode.
See https://platform.openai.com/docs/guides/function-calling?api-mode=responses#strict-mode for more details, but this basically just requires:
additionalPropertiesmust be set to false for each object in the parameters- all fields in properties must be marked as required
def validate_openai_profile(profile: ModelProfile) -> None
Validate an OpenAI-compatible profile after resolution. Called from OpenAIChatModel.__init__.
def openai_model_profile(model_name: str) -> ModelProfile
Get the model profile for an OpenAI model.
def is_openai_live_model(model_name: str) -> bool
Whether a model name belongs to OpenAI’s GPT-Live API rather than its Realtime API.
The two are different protocols on the same provider, so the model name is what picks between
them — see OpenAILiveModel.
def is_openai_computer_use_model(model_name: str) -> bool
Whether OpenAI offers its native computer tool on this model.
GPT-5.4 (with mini and pro), GPT-5.5 (with pro), GPT-5.6 and GPT-6 accept it. GPT-5.4 nano, GPT-5.3 Codex and
GPT-5.2 reject it, though they accept tool search. A new model family gets the computer function tool until it
is added here.
def openai_live_model_profile(model_name: str) -> RealtimeModelProfile
Get the realtime model profile for an OpenAI GPT-Live model.
Live is far more constrained than the Realtime API: it owns turn-taking entirely (no manual turns, no server-side interruption or truncation), speaks rather than writes, takes an image only for its delegated backend to respond to, and seeds from text alone. It also has no end-of-turn frame, so Pydantic AI infers the boundary.
RealtimeModelProfile
def openai_realtime_model_profile(model_name: str) -> RealtimeModelProfile
Get the realtime model profile for an OpenAI realtime model.
RealtimeModelProfile
A reasoning_effort value accepted by the OpenAI API, from least to most reasoning.
Default: Literal['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']
Maps unified thinking values to OpenAI reasoning_effort strings.
'max' maps to 'xhigh' here; OpenAIChatModel and OpenAIResponsesModel send 'max' instead on models whose
profile sets openai_chat_supports_max_reasoning_effort or openai_responses_supports_max_reasoning_effort.
Type: dict[ThinkingLevel, OpenAIReasoningEffort] Default: {True: 'medium', False: 'none', 'minimal': 'minimal', 'low': 'low', 'medium': 'medium', 'high': 'high', 'xhigh': 'xhigh', 'max': 'xhigh'}
Sampling parameter names that are incompatible with reasoning.
These parameters are not supported when reasoning is enabled (reasoning_effort != ‘none’). See https://platform.openai.com/docs/guides/reasoning for details.
Default: ('temperature', 'top_p', 'presence_penalty', 'frequency_penalty', 'logit_bias', 'openai_logprobs', 'openai_top_logprobs')
def openai_codex_model_profile(model_name: str) -> ModelProfile
Get the model profile for OpenAI Codex subscription-auth models.
The Codex backend speaks the Responses API with a narrower dialect than the standard OpenAI
endpoint: it serves streaming responses only, requires store=false, rejects sampling/tuning
request fields (verified live on PR #6433),
rejects the explicit prompt caching fields, and does not expose server-side input-token counting or the Batch API.
def openai_chatgpt_model_profile(model_name: str) -> ModelProfile
Get the model profile for models used through ChatGPT plan usage (Sign in with ChatGPT).
ChatGPT plan usage serves the public Responses API with the narrower dialect OpenAI documents in its
preview limitations:
requests must stream and set store=false, explicit system messages are rejected in favor of
developer ones, sampling, output-limit, and service-tier fields are rejected, only POST /v1/responses is served
(so there is no server-side input-token counting or Batch API), and of the hosted tools only web search is
accepted. tool_search is not accepted, so deferred tools fall back to local search.
Bases: ModelProfile
Profile for models used with AnthropicModel.
ALL FIELDS MUST BE anthropic_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Whether the model supports fast inference speed (anthropic_speed='fast'). Default: False.
Currently Claude Opus 4.6, 4.7, 4.8, 5, and 5.5, Fable 5.2, and Mythos 5.2 support fast mode. See the Anthropic docs for the latest list.
Type: bool
Whether the model supports adaptive thinking (Sonnet 4.6+, Opus 4.6+, Haiku 5.5). Default: False.
When True, unified thinking translates to {'type': 'adaptive'}.
When False, it translates to {'type': 'enabled', 'budget_tokens': N}.
Adaptive thinking, unlike extended thinking, accepts a forced tool_choice, so this also decides whether
an explicit forcing tool_choice raises alongside unified thinking.
Type: bool
Whether the model supports the effort parameter in output_config (Opus 4.5+, Sonnet 4.6+, Haiku 5.5). Default: False.
When True and the unified thinking level is a string (e.g. ‘high’), it is also
mapped to output_config.effort.
Type: bool
Whether the model supports Anthropic-managed dynamic filtering for web search/fetch. Default: False.
When enabled, Pydantic AI selects the web_search_20260209 / web_fetch_20260209 tool versions,
which let Claude filter web results via code execution before they enter context. Anthropic web tool
provider_settings can select the 20260318 versions instead, which also support dynamic filtering.
Type: bool
Whether the model supports the xhigh effort value in output_config. Default: False.
Claude Opus 4.7, 4.8, and 5, Sonnet 5, Fable 5, Mythos 5, and Haiku 5.5 accept xhigh;
on other models, unified thinking='xhigh' uses max instead, or high where max isn’t supported either.
Type: bool
Whether the model supports the max effort value in output_config. Default: True.
Disabled for Claude Opus 4.5, which accepts only low, medium, and high. When disabled, unified
thinking='max' falls back to the highest effort the model accepts (high on Claude Opus 4.5), and so
does thinking='xhigh' where it would otherwise map to max. Explicit anthropic_effort='max' settings
are still passed through unchanged.
Type: bool
Whether the model rejects budget-based thinking settings. Default: False.
Claude Opus 4.7, 4.8, 5, and Haiku 5.5 require adaptive thinking and return a 400 for
{'type': 'enabled', 'budget_tokens': ...}.
Type: bool
Whether the model rejects sampling settings like temperature and top_p. Default: False.
Claude Opus 4.7, 4.8, 5, and 5.5, plus Haiku 5.5, require these settings to be omitted from request payloads.
Type: bool
Whether the model takes temperature only at 1, top_p only from 0.95, and no top_k while it thinks.
Default: False.
Set for every Claude model, which rejects any other temperature, a lower top_p, or a top_k with a 400
while thinking. See
Anthropic’s docs.
Type: bool
Whether the model rejects temperature and top_p set together. Default: False.
Claude Haiku 4.5, Sonnet 4.5 and 4.6, and Opus 4.5 and 4.6 accept one or the other, and return a 400 for both.
Type: bool
Whether the model rejects xhigh/max effort while thinking is explicitly disabled. Default: False.
Claude Opus 5 and Haiku 5.5 cap effort at high when anthropic_thinking={'type': 'disabled'} and return a
400 for xhigh or max, as does Claude Sonnet 5.5 with {'type': 'between_tools'}; Claude Opus 4.8 accepts the
same combination. Claude Opus 5.5 can’t disable thinking at any effort level, so the flag doesn’t apply to it.
Type: bool
Whether thinking=False sends {'type': 'between_tools'} rather than {'type': 'disabled'}. Default: False.
Claude Sonnet 5.5 rejects {'type': 'disabled'} and turns thinking off with {'type': 'between_tools'} instead:
the model doesn’t think before responding, and the short updates it writes between tool calls come back as
thinking blocks.
Type: bool
The Anthropic code execution tool version used when anthropic_code_execution_tool_version='auto'. Default: '20250825'.
Type: AnthropicCodeExecutionToolVersion
The Anthropic code execution tool versions supported by the model. Default: ('20250825',).
Type: tuple[AnthropicCodeExecutionToolVersion, …]
Whether the model supports output_config.task_budget. Default: False.
Anthropic currently documents task budgets as a Claude Opus 4.7 / 4.8 / 5 / 5.5 and Haiku 5.5 beta feature.
Type: bool
Which Anthropic computer use tool or toolset is sent for a ComputerTool. Default: 'computer_20250124'.
Whether ComputerTool is sent at all depends on supported_native_tools.
Type: AnthropicComputerToolVersion
Deprecated: use supports_compaction_on_demand instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
Deprecated: use supports_forced_tool_choice instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
The most output tokens the model can generate in one response, thinking included. Default: None (unknown).
AnthropicModel sends it as max_tokens when the request doesn’t set one, so responses are only cut off at the
model’s limit, like on APIs where the output limit is optional, and lowers a max_tokens above it to it, as
Anthropic rejects that with a 400. BedrockConverseModel does the same for Claude.
Whether the model rejects a request whose input plus max_tokens exceeds its context window. Default: False.
Claude models older than Claude Sonnet 4.5 answer such a request with a 400, where later models accept it and stop
at the context window. When True, a request that doesn’t set max_tokens gets the lower default of 4096, so a
conversation close to the context window still fits. It’s also set for Claude 3 and 3.5, whose maximum output
(4,096 or 8,192 tokens) is below the higher default.
Type: bool
Whether the model binds each thinking block to the conversation prefix that produced it. Default: False.
Claude Fable 5.1 and 5.2, Claude Mythos 5.2, Claude Opus 5.5, Claude Sonnet 5.5, and Claude Haiku 5.5 bind
replayed thinking blocks to the conversation prefix. Anthropic documents a 400 after system, tools, or earlier
messages change; on Fable 5.1, Opus 5.5, Sonnet 5.5, and Haiku 5.5, for accounts created before 31 August 2026,
the error requires thinking.block_binding.prefix_mismatch_behavior. Fable 5.2 and Mythos 5.2 return it on every
account.
When True, Pydantic AI preserves the account’s default behavior on the first request; if Anthropic
rejects a stale block, it retries once with thinking.block_binding.prefix_mismatch_behavior='drop_block'
and warns after the retry succeeds. See Anthropic’s thinking troubleshooting
guide.
Type: bool
Whether the model can read a mid-conversation system entry that directly follows a tool result as part of the tool output. Default: False.
Claude Haiku 5.5 can read a {'role': 'system'} entry that directly follows a tool_result as part of the tool
output, and so not follow it, as Anthropic’s
docs
note. That’s where a loaded on-demand capability’s instructions and an instruction change during a tool loop
land. When True, AnthropicModel ends that user turn with a short text block saying the tool results end
there and the system message comes from the application. Measured live, that block took Haiku 5.5 from 12 to
64 of 64 runs following a rule change; Sonnet 5.5 and Opus 5.5 followed it without the block.
It only applies when a native entry is used. Haiku 5.5’s default profile sends its lasting system messages as
sealed <system> blocks instead (needs_sealed_system_blocks), so that leaves its request-scoped entries.
Type: bool
Whether the API accepts Anthropic Files API file IDs and code execution container IDs. Default: True.
AnthropicModel sets it to False on the Bedrock, Vertex AI and Foundry clients. There, an
UploadedFile from Anthropic raises a UserError, a
CodeExecutionTool’s Anthropic files aren’t uploaded to its
container, and no container from earlier in the history, including a paused turn’s, is sent.
Type: bool
Whether the API rejects a request whose strict schemas exceed Anthropic’s explicit complexity limits. Default: False.
Anthropic counts strict tools, optional parameters and union-typed parameters across all strict schemas in a
request, and rejects recursive schemas, as described under schema complexity
limits. When
True, an output_type that doesn’t pick an output mode uses non-strict Tool Output instead of Native Output where
the Native Output schema wouldn’t fit, and a request that explicitly asks for strict schemas over a limit raises a
ModelRequestRejectedError before it’s sent.
Type: bool
Whether the endpoint serves the Claude API’s
Message Batches. Default: False.
BatchModelRequests and
model_request_batch use it. AnthropicModel sets it for an
AsyncAnthropic client, and not for the Bedrock, Vertex AI and Microsoft Foundry clients, whose platforms batch
through jobs of their own. Message Batches are sent through an AsyncAnthropic client, so setting this for another
client class raises a UserError when a request is batched.
Type: bool
Whether the count_tokens endpoint accepts the web search, web fetch, code execution, tool search and advisor
tools. Default: False.
When True, AnthropicModel.count_tokens sends those tools, and the advisor’s history blocks, as the real request
does, so the count matches its input_tokens. Without them, the count leaves out their definitions, and the
Anthropic API rejects a count whose function tools are all deferred with a 400. When the provider’s profile doesn’t
set it, AnthropicModel turns it on for the AsyncAnthropic client and leaves it off for the Bedrock, Vertex AI
and Foundry clients, whose count endpoints haven’t been verified to accept them. Of the endpoints an
AsyncAnthropic client reaches, the Anthropic API’s and Pydantic AI Gateway’s are verified: set it to False if
your client’s base_url points at a proxy whose count endpoint rejects server tools.
Type: bool
Whether a request that asks for citations sends the 20260209 or 20260318 web tools it cites with
allowed_callers=['direct'], so their results are cited. Default: False.
See Web Tool Callers for the requests that keep the default callers.
When the provider’s profile doesn’t set it, AnthropicModel turns it on for the AsyncAnthropic client and leaves
it off for every other client. Of those, Claude Platform on AWS (AsyncAnthropicAWS) and Microsoft Foundry also
send those versions, but haven’t been verified to accept allowed_callers with citations.
Type: bool
Whether the endpoint takes the inference_geo request parameter for
data residency. Default: False.
When False, anthropic_inference_geo
is ignored with a UserWarning. When the provider’s profile doesn’t set it, AnthropicModel turns it on for the
AsyncAnthropic client, which also serves Claude Platform on AWS and Claude on Google Cloud (Anthropic managed),
and leaves it off for the Bedrock, Vertex AI and Foundry clients, where the endpoint or deployment decides the
inference region. Set it in the provider’s profile or with profile= for a client that forwards the parameter to
the Claude API. It doesn’t depend on the model: models that don’t support data residency reject the parameter
with a 400.
Type: bool
Whether the endpoint serves Anthropic
message threads. Default: False.
When False,
anthropic_previous_message_id
is ignored with a UserWarning. When the provider’s profile doesn’t set it, AnthropicModel turns it on for the
AsyncAnthropic client, which also serves Claude Platform on AWS and Claude on Google Cloud (Anthropic managed),
and for the Foundry client, and leaves it off for the Bedrock and Vertex AI clients, where Anthropic doesn’t offer
threads. Set it in the provider’s profile or with profile= for a client that forwards threads to the Claude API.
Type: bool
def resolve_anthropic_effort(
level: ThinkingEffort,
*,
supports_xhigh: bool,
supports_max: bool = True,
) -> AnthropicEffort
Resolve a unified thinking effort level to the Anthropic output_config.effort value.
Shared between the direct Anthropic path and any provider that translates to the
Anthropic output_config wire shape (e.g. Bedrock Converse for Anthropic models).
Keeps ANTHROPIC_THINKING_EFFORT_MAP as the single source of truth for the
base mapping, while letting the xhigh and max support decisions live in one place.
AnthropicEffort
def resolve_anthropic_thinking_display(
display: AnthropicThinkingDisplay | None,
thinking_summary: bool | None,
) -> AnthropicThinkingDisplay | None
Resolve the thinking.display the settings ask for, or None when they leave it unset.
A provider-specific display setting wins over the unified thinking_summary. A thinking block built from the
unified thinking setting falls back to 'summarized' when this returns None, since the newer Claude models
default to 'omitted' and would otherwise return empty thinking.
Shared between the direct Anthropic path and Bedrock Converse for Claude models, like
resolve_anthropic_effort.
AnthropicThinkingDisplay | None
def anthropic_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for an Anthropic model.
The unified sampling settings gated by anthropic_disallows_sampling_settings.
Models whose profile sets that flag reject these settings outright with a 400, so every provider
serving them has to drop and warn rather than forward. It lives here rather than beside either
model because models/bedrock.py cannot import from models/anthropic/ without pulling the
anthropic SDK into the bedrock extra.
Default: ('temperature', 'top_p', 'top_k')
Concrete Anthropic code execution tool version to send for CodeExecutionTool.
Type: TypeAlias Default: Literal['20250825', '20260120']
Anthropic computer use tool version to send for ComputerTool.
Type: TypeAlias Default: Literal['computer_toolset_20260801', 'computer_20251124', 'computer_20250124']
Maps unified thinking values to Anthropic budget_tokens for non-adaptive models.
Type: dict[ThinkingLevel, int] Default: {True: 10000, 'minimal': 1024, 'low': 2048, 'medium': 10000, 'high': 16384, 'xhigh': 32768, 'max': 32768}
Effort values Anthropic accepts at output_config.effort.
Type: TypeAlias Default: Literal['low', 'medium', 'high', 'xhigh', 'max']
Maps unified thinking effort levels to Anthropic output_config.effort.
xhigh maps to 'max' by default; callers that target a model with
anthropic_supports_xhigh_effort should pass supports_xhigh=True to
resolve_anthropic_effort
to preserve xhigh instead of upshifting, and supports_max=False for a model without
anthropic_supports_max_effort, where 'max' falls back to the highest level it accepts.
Type: dict[ThinkingEffort, AnthropicEffort] Default: {'minimal': 'low', 'low': 'low', 'medium': 'medium', 'high': 'high', 'xhigh': 'max', 'max': 'max'}
Values Pydantic AI sends at thinking.display: a summary of the model’s thinking, or only its signature.
Type: TypeAlias Default: Literal['summarized', 'omitted']
Bases: ModelProfile
Profile for models used with GoogleModel.
ALL FIELDS MUST BE google_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Whether the model supports combining function declarations with native tools and response_schema. Default: False.
Gemini 3+ supports all tool combinations:
- function_declarations + native_tools
- output_tools (function declarations) + native_tools
- response_schema (NativeOutput) + function_declarations See https://ai.google.dev/gemini-api/docs/tool-combination
Type: bool
Whether the model accepts the include_server_side_tool_invocations tool-config field. Default: False.
When enabled, Gemini emits explicit tool_call/tool_response parts for server-side
native tools (Google Search, URL Context, File Search) that we round-trip through
NativeToolCallPart /
NativeToolReturnPart. Pre-Gemini-3 models
reject the field with 'Tool call context circulation is not enabled'.
This is a Gemini Developer API (ML Dev) only parameter: the google-genai SDK’s Vertex
converter raises ValueError when the field is set, so GoogleModel skips it for
Google Cloud (Vertex) even on Gemini 3+ models.
Distinct from google_supports_tool_combination
even though both currently flip on for Gemini 3+ — the former gates the SDK request
field, the latter gates which combinations of native / function / output tools are
allowed in the same request.
Type: bool
MIME types supported in native tool results: GenerateContent’s FunctionResponseDict.parts
or Interactions’ function_result. Default: ().
See https://ai.google.dev/gemini-api/docs/function-calling#multimodal-function-responses
Whether the model uses thinking_level (enum: LOW/MEDIUM/HIGH) instead of thinking_budget (int). Default: True.
Gemini 3+ models use thinking_level; older models (e.g. Gemini 2.5) use thinking_budget.
Type: bool
Whether the model accepts thinking_level='MINIMAL'. Default: True.
Derived from google_thinking_levels
when that is set. Sparse profiles without the level set fall back to this flag: when disabled,
unified thinking='minimal' and thinking=False resolve to thinking_level='LOW'.
See https://ai.google.dev/gemini-api/docs/thinking.
Type: bool
Whether unified thinking=False turns thinking off with thinking_budget=0 on a model that otherwise
takes thinking_level. Default: False.
When disabled, thinking=False on such a model sends its lowest thinking level instead. GoogleModel enables it
for gemini-3.1-pro-preview on Vertex AI, which accepts thinking_budget=0 and then doesn’t think, while the
Gemini API rejects it for that model (“Budget 0 is invalid. This model only works in thinking mode.”).
Type: bool
The thinking_budget that unified thinking='minimal' sends on a model that takes thinking_budget.
Default: 128, the smallest budget Gemini 2.5 Pro accepts.
GoogleModel sets 512 for gemini-2.5-flash-lite on the Gemini API, which rejects budgets below 512 there.
See https://ai.google.dev/gemini-api/docs/thinking#set-budget.
Type: int
Thinking levels the model supports, from Google’s per-model thinking table. Default: unset.
Unset means GOOGLE_THINKING_LEVELS is assumed: every
level but XHIGH. Unified thinking efforts snap to the nearest supported level.
See https://ai.google.dev/gemini-api/docs/thinking.
Type: frozenset[GoogleThinkingLevel]
Whether the model supports Gemini’s VALIDATED function-calling mode. Default: False.
VALIDATED is Gemini’s equivalent of the cross-provider strict tool flag (like OpenAI/Anthropic
strict tool calling): it behaves like AUTO but the API enforces that the model adheres to the
declared function schema. Issue reports also observe that it mitigates the function-name hallucination
some Gemini models exhibit (an observed effect, not a documented guarantee). When the flag is set,
GoogleModel upgrades AUTO to VALIDATED by default (every schema is VALIDATED-compatible — no
rewrites), and a caller opts out per tool with ToolDefinition.strict=False. Because Gemini’s mode is
request-wide, any function or output tool with strict=False keeps the whole request on AUTO.
See https://ai.google.dev/gemini-api/docs/function-calling#function_calling_config.
Type: bool
Whether Google Search grounding is billed once per grounded prompt rather than per search query. Default: False.
Gemini 2.5 and older bill a request once, however many queries it ran, and only when it returned a web source;
Gemini 3+ bills each unique search query. This decides the web_searches count on
RequestUsage.
See https://ai.google.dev/gemini-api/docs/google-search#pricing.
Type: bool
Whether the model accepts presence_penalty and frequency_penalty. Default: True.
The Gemini API rejects them for every model, so GoogleModel turns this off when its client talks to the Gemini
API. On Google Cloud (Vertex AI), Gemini 3.5 Flash-Lite, Gemini 3.6 Flash and newer, and the Gemini 3 image models
reject them with a 400.
Type: bool
Whether the endpoint serves the Gemini API’s Batch Mode.
Default: False.
BatchModelRequests and
model_request_batch use it. GoogleModel sets it when its client
talks to the Gemini API, and not on Google Cloud (Vertex AI), whose batch prediction jobs read from Cloud Storage
or BigQuery rather than the uploaded files GoogleModel submits.
Type: bool
Whether the model takes Google’s computer use tool.
Default: False.
Without it, GoogleModel leaves ComputerTool out of
supported_native_tools, so a computer tool goes to the model as a function tool. google_model_profile sets it for
the models Google lists, and GoogleModel turns it off on Google Cloud (Vertex AI), where the tool is unverified.
Set it with profile= for a model you have checked.
Type: bool
Bases: JsonSchemaTransformer
Transforms the JSON Schema from Pydantic to be suitable for Gemini.
Gemini supports a subset of OpenAPI v3.0.3.
Bases: GoogleJsonSchemaTransformer
Transforms the JSON Schema from Pydantic into the OpenAPI v3.0.3 subset Gemini’s Schema accepts.
A function declaration carries its parameters as either parametersJsonSchema (full JSON Schema,
which GoogleModel sends) or parameters (an
OpenAPI v3.0.3 subset) —
the two are mutually exclusive. The Live API only implements parameters, so
GoogleRealtimeModel needs this narrower form,
where a union is anyOf, an enum is a list of strings, and there are no $refs to resolve.
def google_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Google model.
def google_cloud_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Google model served by Vertex AI.
def google_interactions_model_profile(model_name: str) -> GoogleModelProfile
Profile overrides for Google’s Interactions API, independent of GenerateContent.
GoogleModelProfile
def google_realtime_model_profile(model_name: str) -> RealtimeModelProfile
Get the realtime model profile for a Gemini Live model.
RealtimeModelProfile
Native Gemini thinking_level values.
Type: TypeAlias Default: Literal['MINIMAL', 'LOW', 'MEDIUM', 'HIGH', 'XHIGH']
The full thinking-level scale, cheapest first. The resolver’s order map derives from this.
Type: tuple[GoogleThinkingLevel, …] Default: ('MINIMAL', 'LOW', 'MEDIUM', 'HIGH', 'XHIGH')
The levels assumed for a model without a documented level set: the scale without XHIGH.
Only models whose google_thinking_levels list XHIGH take it; Gemini 3 models reject it with a 400.
Type: frozenset[GoogleThinkingLevel] Default: frozenset(('MINIMAL', 'LOW', 'MEDIUM', 'HIGH'))
def meta_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Meta model.
def muse_model_profile(model_name: str) -> OpenAIModelProfile | None
Get the model profile for a Meta Muse model, or None if model_name isn’t one.
OpenAIModelProfile | None
def amazon_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for an Amazon model.
def deepseek_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a DeepSeek model.
Bases: ModelProfile
Profile for Grok models (used with XaiProvider and various OpenAI-compatible providers).
ALL FIELDS MUST BE grok_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Whether the model supports builtin tools (web_search, x_search, code_execution, mcp). Default: False.
Type: bool
Deprecated: use supports_forced_tool_choice instead.
Translated (with a deprecation warning) whenever profiles are merged.
Type: bool
Native reasoning_effort values supported by the Grok model. Default: empty (frozenset()).
Type: frozenset[GrokReasoningEffort]
Whether a default thinking request omits reasoning_effort so xAI applies its model default. Default: False.
Type: bool
Whether the model accepts stop_sequences. Default: True.
Only the Grok 4.20 non-reasoning models do: the others reject them with a 400.
Type: bool
def grok_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Grok model.
def grok_realtime_model_profile(model_name: str) -> RealtimeModelProfile
Get the realtime model profile for an xAI Grok Voice model.
RealtimeModelProfile
Native xAI reasoning_effort values.
Type: TypeAlias Default: Literal['none', 'low', 'medium', 'high']
Bases: ModelProfile
Profile for Mistral models (used with MistralProvider).
ALL FIELDS MUST BE mistral_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Native reasoning_effort values the model accepts. Default: unset.
When unset, a model with adjustable reasoning maps every enabled thinking level to 'high' and
thinking=False to 'none'. When set, each level maps to the closest accepted effort, and
thinking=False to 'none' if accepted, else the lowest accepted effort.
Type: frozenset[MistralReasoningEffort]
def mistral_model_profile(model_name: str) -> ModelProfile
Get the model profile for a Mistral model.
Native Mistral reasoning_effort values, from least to most reasoning.
Type: TypeAlias Default: Literal['none', 'minimal', 'low', 'medium', 'high', 'xhigh']
def qwen_model_profile(model_name: str) -> ModelProfile | None
Get the model profile for a Qwen model.
Bases: ModelProfile
Profile for models used with GroqModel.
ALL FIELDS MUST BE groq_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
Whether the model always has the web search built-in tool available. Default: False.
Type: bool
Whether thinking=False truly disables reasoning via reasoning_effort='none'. Default: False.
Only the qwen3 family supports this; other Groq reasoning models can at most suppress reasoning
output via reasoning_format='hidden' while still reasoning internally.
Type: bool
Whether the model accepts graded reasoning_effort values (low/medium/high). Default: False.
Only the gpt-oss family supports this; unified thinking levels map to those values via
GROQ_GPT_OSS_REASONING_EFFORT_MAP.
The qwen3 family instead only accepts none/default (see groq_supports_reasoning_disable).
Type: bool
def groq_model_profile(model_name: str) -> ModelProfile
Get the model profile for a Groq model.
Maps unified thinking effort levels to the graded reasoning_effort values the gpt-oss family accepts.
gpt-oss only accepts low/medium/high (not none/default), so minimal folds into low and
xhigh and max into high. thinking=True (bare enable) maps to medium in GroqModel, mirroring the neutral
default other providers use. See the Groq docs.
Type: dict[ThinkingEffort, Literal[‘low’, ‘medium’, ‘high’]] Default: {'minimal': 'low', 'low': 'low', 'medium': 'medium', 'high': 'high', 'xhigh': 'high', 'max': 'high'}
Bases: ModelProfile
Profile for Z.AI (Zhipu AI) GLM models.
Whether the model accepts a per-request reasoning_effort level (GLM-5.2 and GLM-5.3).
Type: bool
Substitutions applied to the unified thinking effort level before it is sent as reasoning_effort.
Levels not in the mapping are forwarded unchanged. GLM-5.2 accepts all unified levels, so it needs no
mapping; GLM-5.3 only accepts low/high/max (per the Z.AI docs and the error message returned when
disabling thinking on it), so its other unified levels are mapped.
def zai_model_profile(model_name: str) -> ModelProfile | None
The model profile for ZAI (Zhipu AI) GLM models, matched by Z.AI’s native glm-* ids.
Marks thinking-capable models (glm-5, glm-4.7, glm-4.6, glm-4.5) via supports_thinking=True.
This includes the glm-4.6v and glm-4.5v vision models, which also support thinking mode per the
Z.AI docs. GLM-5.2 and GLM-5.3 additionally accept a per-request reasoning effort level, flagged via
zai_supports_reasoning_effort=True. GLM-5.3 always reasons and cannot disable thinking, flagged via
thinking_always_enabled=True.
GLM-5.3 stringifies nested tool arguments whose schema is a $ref into $defs, so its schemas
are inlined via InlineDefsJsonSchemaTransformer. See https://github.com/pydantic/pydantic-ai/issues/10243.
The provider-specific request/response shape (e.g. the reasoning_content field used by Z.AI’s API)
is configured in ZaiProvider.model_profile() rather than here. Providers that serve GLM models under
a different id scheme (e.g. Cerebras’s zai-glm-*, which doesn’t match the glm-* prefixes above)
configure thinking support in their own model_profile().
def minimax_model_profile(model_name: str) -> ModelProfile | None
The model profile for a MiniMax model, matched by its published minimax-* id.
MiniMax models stringify nested tool arguments whose schema is a $ref into $defs (recorded in
https://github.com/pydantic/pydantic-ai/issues/12077, first reported in
https://github.com/pydantic/pydantic-ai/issues/7728), so their schemas are inlined.
The function takes the dotted id MiniMax publishes (minimax-m3.1-flash). Unpublished ids, minimax-m2-her
(which doesn’t reason) and legacy minimax-01 return None.
def nvidia_model_profile(model_name: str) -> ModelProfile | None
The model profile for an NVIDIA Nemotron model, matched by its published id.
The function takes the id gateways publish (nemotron-3-super-120b-a12b) or NVIDIA’s Hugging Face repo name
(NVIDIA-Nemotron-3-Super-120B-A12B-FP8). Nemotron 3 Super and Ultra think by default and can be turned off;
Nemotron 3.5 Super and Lightning think when asked to. Other NVIDIA models, including ones that don’t reason such
as nemotron-mini-4b-instruct, return None.
def thinkingmachines_model_profile(model_name: str) -> ModelProfile | None
The model profile for a Thinking Machines Inkling model, matched by its published id.
Inkling and Inkling Small think by default and can be turned off. Other ids return None.
def xiaomi_model_profile(model_name: str) -> ModelProfile | None
The model profile for a Xiaomi MiMo model, matched by its published id.
MiMo V2.5 and V2.6 (mimo-v2.5-pro, mimo-v2.6-flash, …) think when asked to. Other ids return None.
def stepfun_model_profile(model_name: str) -> ModelProfile | None
The model profile for a StepFun Step model, matched by its published id.
Step 5 (step-5-preview) and Step 3.7 (step-3.7-flash) always think. Other ids return None.
def tencent_model_profile(model_name: str) -> ModelProfile | None
The model profile for a Tencent Hy model, matched by its published id.
Hy3 and Hy4 (hy4, hy4-flash, …) think by default and can be turned off. Other Tencent models, including
ones that don’t reason such as the hy-mt2 translation models, return None.
def inclusionai_model_profile(model_name: str) -> ModelProfile | None
The model profile for an InclusionAI Ling model, matched by its published id.
Ling 3 (ling-3.0-flash, ling-3.1-flash, …) thinks by default and can be turned off. Other ids return None.
Bases: ModelProfile
Profile for a decision model: what the model can be asked.
These are facts about the model behind the URL, not the class that talks to it, so they are set by the provider
for the model name, or by profile=. A key left out falls back to the class’s
max_choice_options,
max_score_levels and
requires_instructions.
ALL FIELDS MUST BE decision_ PREFIXED SO YOU CAN MERGE THEM WITH OTHER MODELS.
The most options the model accepts in one pick-one question, or None for no limit.
A pick-one field with more options, or more routes than this on the route question, is a
UserError before a request is sent.
The most levels the model accepts in one rubric, or None for no limit.
Whole numbers from 0 with more levels than this are not a rubric, so a field of them is asked as a pick-one
instead, and counts against decision_max_choice_options.
Whether the model refuses a question without instructions.
A pick-one, a rubric, or a yes/no with described answers with nothing else to ask is then sent with a generic
question, 'Which of these applies?', instead of no instructions at all.
Type: bool
def decision_model_profile(model_name: str) -> ModelProfile
Get the model profile for a decision model.
A decision model answers typed questions about a state; it does not generate text or tool calls.
Tool-mode structured output is how a decision model fills an output_type, and it rides on supports_tools,
so that stays on. A system prompt anywhere in the history is part of what the model judges, so it needs no
wrapping. Image input is declared by the adapter’s
supports_image_input, rather than by this
profile. The model refuses unsupported input itself.
def cloudflare_model_profile(model_name: str) -> ModelProfile | None
Get conservative capabilities for native Workers AI models.
A chat model gets its family’s profile from the vendor/model part of its ID, with the input, tool and output
capabilities Workers AI was verified to serve on top. Unlisted chat models accept text. Override the profile
explicitly to enable additional capabilities.
def cloudflare_decisions_model_profile(model_name: str) -> ModelProfile
Get the profile for a Clef decision model on Workers AI.
Clef and Clef Flash get their context windows and Cloudflare’s question limits. Another Clef ID gets the plain decision model profile, never a chat model’s.