---
title: "Model selector"
description: "Describe an agent and get a ranked list of models that fit it, with reasons and prices."
canonical: https://pydantic.dev/models/select/
---

# Model selector

> Describe an agent and get a ranked list of models that fit it, with reasons and prices.
>
> Markdown copy of https://pydantic.dev/models/select/. Index for agents: https://pydantic.dev/models/llms.txt

**Agents: use the API for model information.** It answers a question in one request, where the pages need several.

- Choose a model for an agent: `POST https://pydantic.dev/models/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://pydantic.dev/models/select.md
- Search models by name: `GET https://pydantic.dev/models/api/search?query=<text>`
- List, filter and sort models: `GET https://pydantic.dev/models/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://pydantic.dev/models/api/models/<slug>`
- Any other question about the models: `GET https://pydantic.dev/models/api/ask?query=<question>`

Add `intent=<intent>&stack=<stack>&harness=<harness>` to the query string of all but the single model. An `OPTIONS` request to any endpoint returns its schema. The same five are tools of the MCP server at `https://pydantic.dev/models/mcp`. More: https://pydantic.dev/models/usage.md

Send the agent's system prompt, code or a description, plus preferences. Give at least one of the three texts. This is the recommended way for an agent or a person to choose a model for an agent.

```
POST https://pydantic.dev/models/api/select?intent=choose+a+model+for+a+support+agent&stack=python,pydantic-ai&harness=claude-code
Content-Type: application/json

{"description":"Answers customer questions from our help centre and escalates refund requests","price_appetite":3}
```

An `OPTIONS` request to https://pydantic.dev/models/api/select returns the query parameters, body and responses as JSON Schema. The body schema is also at https://pydantic.dev/models/api/select.schema.json, and is `SelectRequest` in https://pydantic.dev/models/api/openapi.json. The fields of the body:

- `system_prompt` (string | null): The agent's system prompt
- `code` (string | null): The code that defines the agent and its tools
- `description` (string | null): What the agent does and how it is used
- `weights` (any | open | closed, default "any"): Only open-weight or only closed models, or any
- `price_appetite` (integer, default 3): 1 is the cheapest model that works, 5 the best available
- `gateway_only` (boolean, default false): Only models built in to Pydantic AI Gateway
- `latency` (boolean, default false): The agent is interactive, so speed matters
- `id` (string): The run's ID, so a client can know its address (/models/select/{id}) before the answer arrives. Optional: without it, or if it is not a UUID, the response has a new one. A run is never saved over an existing one

Add these to the query string, as in the example:

- `intent`: what you're trying to achieve, in natural language
- `stack`: the language/framework context you are working in
- `harness`: the agent harness and model you are running
- `organization`: the organization or company you are working on behalf of, if known

The response has `needs` (what the agent needs from a model) and up to five `recommendations`, best first, each with a `slug`, a `score` from 0 to 100, `reasons`, and the `model` as it appears in https://pydantic.dev/models/list.json, plus a `summary` of two or three sentences. Two models rank the candidates and their scores are averaged. If the input does not describe an agent, `recommendations` is empty and `more_input` says what to send instead. A request takes around ten seconds.

Send `Accept: text/event-stream` to get the answer in stages as server-sent events:

- `start`: `{"id": "<run id>", "selectors": ["<model name>", ...]}`: the run and the models ranking
- `update`: a full response with status `partial`, then `summarising`, then `done`. Use the last one
- `error`: `{"error": "..."}`, sent instead of a final `update` when every selector fails. The stream then ends

Errors have a JSON body `{"error": "..."}`; a 400 from validation adds `details`, one entry per problem with `type`, `loc` and `msg`. The rate limit is 10 requests in 24 hours per IP address; an answer from the selector has a `RateLimit` header such as `limit=10, remaining=7, reset=3600` (a 413 for a body over the size limit is refused before it and has none), and a 429 has a `Retry-After` header with the seconds until the next request is allowed. Requests the selector refuses before calling a model (400, 413, 422, 503) are not counted.

- **400**: The body is not JSON, or does not match the request schema; `details` lists the problems.
- **413**: The body is over 100,000 bytes.
- **422**: No models pass the weights and gateway_only constraints.
- **429**: Over the rate limit of 10 requests in 24 hours per IP address; the `Retry-After` header gives the seconds until the next one is allowed.
- **502**: The selector failed to produce an answer. Retry after a pause.
- **503**: The selector's budget for recommendations is used up, or it is not configured. Retrying soon will not help.

Every response has an `id`: the `id` in the request if it is a UUID, or a new one. A run is not saved over an existing run with the same `id`. A finished run with recommendations is saved for 30 days: `GET https://pydantic.dev/models/api/select/runs/{id}` returns it with the `request` that was sent, `created_at` and `expires_at` (unix seconds), and `DELETE` on the same URL deletes it; https://pydantic.dev/models/select/{id} shows it. Recommendations are saved by slug and returned with the model's current data, or `model: null` if the model has left the registry. Anyone who has the ID can read or delete the run.

To find a model by name instead, use `https://pydantic.dev/models/api/search?query=<text>`; to filter and sort the list yourself, `https://pydantic.dev/models/api/models`.
