Guides
Model Routing
Route requests to different models based on your requirements.
Model Routing
AssistantRouter lets you choose from multiple AI models across providers and configure fallback behavior.
Available Models
AssistantRouter supports models from multiple providers:
| Provider | Models |
|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo |
| Anthropic | claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-haiku-20240307 |
gemini-1.5-pro, gemini-1.5-flash |
All models are available on all tiers. There are no tier-based model restrictions.
Explicit Model Selection
Specify a model directly in your request:
const response = await client.chat.completions.create({
model: 'claude-3-haiku-20240307',
messages: [{ role: 'user', content: 'Hello!' }],
});Model Fallbacks
Configure a fallback model on your assistant so that if the primary model is unavailable, requests automatically retry with the fallback:
const assistant = await fetch('https://api.assistantrouter.com/v1/assistants', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Reliable Assistant',
model: 'claude-3-5-sonnet-20241022',
model_config: {
fallback_models: ['gpt-4o', 'gemini-1.5-pro'],
max_retries: 3,
},
}),
}).then(r => r.json());Model Pricing
Costs vary by model and are deducted from your wallet. Prices are sourced dynamically from OpenRouter at the time of each request.
View the cost of each request in the response's x_assistantrouter.cost_millicents field.
Best Practices
- Start cheap - Use faster/cheaper models (Gemini 1.5 Flash, Claude 3 Haiku) for simple tasks
- Use fallbacks - Always configure backup models
- Monitor costs - Track spending in the dashboard
- Test models - Different models excel at different tasks
- Consider latency - Smaller models are faster