In short.
Select Model is a page in the documentation for PydanticAI, a Python library for building AI agents, showing developers how to switch an agent between AI models during a run, with routing decisions and retry budgets controlled by their own code. It explains context-based selection and illustrates switching to a backup after output rejection while retaining history and the retry count across a tool call. The page provides no measured quality, latency or cost comparison. Its examples were not executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete Select Model page at [https://pydantic.dev/docs/ai/capabilities/select-model/index.md], including its documentation-index and query-parameter notices and both code examples. Linked documentation and index contents are excluded. Library source, provider services and separate licensing materials were not assessed. No code was executed; compatibility, runtime behavior, model availability, quality, latency and cost remain unverified.
The overview
Identity
Select Model is a feature guide in the PydanticAI documentation at [https://pydantic.dev/docs/ai/capabilities/select-model/index.md]. It describes SelectModel, a capability attached to an Agent that chooses which model handles a request. The resource is documentation for a Python library feature.
Assessment
The guide is useful when an application already has a rule for choosing models, such as an explicit task-complexity label or a rejected output. It gives concrete implementation patterns and explains when selection happens.
It does not establish that escalation produces better answers or lower costs. The first example receives a complexity label from application dependencies; it does not demonstrate automatically estimating task difficulty.
Users
The clearest audience is Python developers using PydanticAI who need different models for different tasks or stages of an agent run. Developers implementing output validators may particularly benefit from the retry example.
Beginners will need familiarity with Python functions, type annotations and agent dependencies. The second example also assumes an understanding of function tools, message history and output validation.
Capabilities
A selector can use dependencies, the prompt, message history, usage, the current step, run identifiers, deadline and usage limits. It also receives the output rejection count and retry budget through ctx.retry and ctx.max_retries.
The callable can be synchronous or asynchronous. The examples demonstrate returning a model identifier or a FunctionModel instance. Selection during setup allows the Agent to omit a constructor model.
Using it
Requirements
The examples require Python and PydanticAI imports including Agent, ModelSelectionContext and SelectModel. Dependency-based routing also uses a dataclass describing the values available to the selector.
The page does not specify installation commands, a minimum PydanticAI release, supported Python versions or provider authentication steps. The output-retry demonstration uses local FunctionModel responses in place of external model calls.
Mechanism
The selector is first evaluated during run setup and is evaluated before each new logical model request step. Returning the same model identifier on later steps reuses its resolved model/provider instance within that run. Provider continuation polling inside a step remains pinned to that step's selected model.
Output rejection counts persist across intervening function tool calls. A selector using ctx.retry >= 1 can therefore keep choosing the backup after the first rejected output while preserving the run's history and output retry budget.
Setup
Import Agent and ModelSelectionContext from pydantic_ai and SelectModel from pydantic_ai.capabilities. Define a callable accepting the selection context, then attach SelectModel(your_callable) through the Agent's capabilities argument.
The dependency example declares task_complexity as either standard or complex and passes Deps as deps_type. The output-retry example instead inspects ctx.retry and configures retries={'output': 1}. These are feature examples rather than a complete installation and provider-configuration walkthrough.
Example
The complexity example maps complex tasks to openai:gpt-6.1-sol and standard tasks to openai:gpt-6-luna. These are the identifiers printed in the source; the page's comment describes openai:gpt-6.1-sol as the larger model, but their availability, measured capability and pricing are not established by this page.
The retry example uses deterministic FunctionModel stand-ins. The primary returns draft, which the validator rejects with ModelRetry. The backup then requests look_up_answer and returns ready after the tool response. The documented response-model sequence is primary, backup, backup, and the validator's retry states are (0, 1) and (1, 1). These are illustrated outputs, not independently observed execution results.
Assessment & evidence
Limitations
Switching models does not reset the output retry budget. With retries={'output': 1}, the backup receives one output attempt; rejection of that output raises UnexpectedModelBehavior.
The page demonstrates routing after output rejection, not automatic recovery from provider or transport failures. Cross-provider tool compatibility, selector failure handling, production reliability and performance are not assessed. Detailed precedence and lifecycle rules are deferred to linked documentation.
Why this approach may fit
The examples suggest two practical routing strategies: use an application-provided task label before requesting an answer, or escalate after an output validator rejects one. Both make the application's decision rule explicit.
A reasonable inference is that retry-based escalation is only as useful as the validator's ability to recognize unacceptable output. The example rejects a literal draft string; it does not establish detection of factual errors or suitability for broader quality judgments.
Alternatives
For an application with a fixed model choice, using the constructor model mentioned by the page may be simpler. This is an implementation judgment, not a measured comparison.
The page also points to implementing a selection hook in a custom capability. That implementation and its precedence rules are outside this page. Other routing libraries and managed routing services are not compared.
Evidence
The supporting source is the complete Select Model documentation page at [https://pydantic.dev/docs/ai/capabilities/select-model/index.md]. It provides API explanations, two code examples and expected printed output. It supplies no independent benchmark or production case study.
The examples' runtime behavior has not been independently verified.
Access & freshness
Costs
Provider pricing, any applicable library charges and total operating cost are unknown from this page. It supplies no cost comparison or measured savings.
The illustrated retry flow contains multiple logical model requests. An equivalent implementation using external providers would need to account for the initial request, escalation and subsequent requests when estimating spending.
Rights
This page contains no explicit license or reuse terms for its prose or code examples. Redistribution permission and any separate library or model-provider terms are not established by this source.
Freshness
This report reflects the page as captured on 15 November 2026 at 08:44:18.376 UTC. The page states no publication date, last-updated date or package release associated with the examples.
The capture timestamp does not establish compatibility with a particular installed release or continued availability of the named models. Those details remain unknown.
Practical next steps
Before adopting the pattern, confirm that your installed PydanticAI release supports SelectModel and ModelSelectionContext, verify the intended models' availability and terms, and configure provider access.
Evaluate your routing rule with representative tasks. Include output rejection followed by a tool call and exhaustion of the output retry budget. Measure answer quality, latency and total usage before relying on any expected benefit from switching models.
