Auto Router
Automatic model selection based on prompt intent
Set model to therouter/auto to delegate model selection to TheRouter.ai. The router evaluates prompt complexity and task type, then forwards to a suitable model.
TypeScript
const response = await fetch('https://api.therouter.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer <THEROUTER_API_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'therouter/auto',
messages: [
{ role: 'user', content: 'Explain quantum entanglement for a 12-year-old.' },
],
}),
});
const data = await response.json();
console.log('Selected model:', data.model);Restricting candidate models
Use provider preferences to constrain selection to approved model families.
json
{
"model": "therouter/auto",
"messages": [{ "role": "user", "content": "Draft an architecture decision record." }],
"provider": {
"only": ["anthropic", "openai"]
}
}Pricing
Auto Router has no additional surcharge. Billing uses the standard price of the model selected for the request.