> For the complete documentation index, see [llms.txt](https://docs.fastrouter.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastrouter.ai/api-reference/auto-router.md).

# Auto Router

## Get Model Selection

> Returns the optimal model recommendation for a given prompt without making the actual completion request. Uses FastRouter's intelligent routing engine.\
> \
> \*\*Available at both:\*\*\
> \- \`POST <https://api.fastrouter.ai/api/v1/model/selection\\`\\>
> \- \`POST <https://api.fastrouter.ai/v1/model/selection\\`\\>
> \
> Set model to \`fastrouter/auto\` for automatic selection.

```json
{"openapi":"3.1.0","info":{"title":"FastRouter API Reference","version":"1.0.0"},"tags":[{"name":"Model Selection","description":"Get the optimal model recommendation for a given prompt without making the actual completion request. Uses FastRouter's intelligent routing engine."}],"servers":[{"url":"https://api.fastrouter.ai","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"FastRouter API Key. Get yours at https://fastrouter.ai\n\nFormat: `Authorization: Bearer YOUR_API_KEY`"}},"responses":{"BadRequestError":{"description":"Bad Request - The request is malformed. This could be due to missing parameters, invalid formats, or routing errors.\n\n**Note:** the 400 body shape is not uniform. Validation errors return the structured object below, but routing/model errors may instead return a plain string: `{ \"error\": \"<message>\" }`. A few endpoints (e.g. some file operations) may return a plain-text body rather than JSON.","content":{"application/json":{"schema":{"oneOf":[{"type":"object","description":"Structured validation error.","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"}}}}},{"type":"object","description":"Plain-string routing/model error.","properties":{"error":{"type":"string"}}}]}}}},"UnauthorizedError":{"description":"Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.\n\nNote: the 401 error body uses `code`, `message`, `param`, and `type` (there is no `status` field), and `type` is `invalid_request_error`.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}}}},"InternalServerError":{"description":"Internal Error - Something went wrong on our side. Retry the request, and contact support if the issue persists.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}}}},"paths":{"/api/v1/model/selection":{"post":{"operationId":"getModelSelection","tags":["Model Selection"],"summary":"Get Model Selection","description":"Returns the optimal model recommendation for a given prompt without making the actual completion request. Uses FastRouter's intelligent routing engine.\n\n**Available at both:**\n- `POST https://api.fastrouter.ai/api/v1/model/selection`\n- `POST https://api.fastrouter.ai/v1/model/selection`\n\nSet model to `fastrouter/auto` for automatic selection.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Set to `fastrouter/auto` for auto selection, or provide a specific model ID."},"messages":{"type":"array","description":"Conversation messages. The routing engine analyzes these to determine the optimal model.","minItems":1,"items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{"type":"string"}}}}}}}}},"responses":{"200":{"description":"Model selection result","content":{"application/json":{"schema":{"type":"object","properties":{"selected_model":{"type":"string","description":"The recommended model ID"},"assigned_tags":{"type":"array","items":{"type":"string"},"description":"Tags assigned to the prompt"},"top_candidates":{"type":"array","items":{"type":"string"},"description":"Top candidate models"},"selection_strategy":{"type":"string","enum":["auto","explicit"]},"error":{"type":"string","description":"Error message if selection encountered issues"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fastrouter.ai/api-reference/auto-router.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
