Skip to main content
Docs
Alvin Intelligent Routing

Alvin Intelligent Routing

Learn how Alvin automatically selects the optimal AI model for each request.

Alvin is Elyxir's intelligent routing system that automatically selects the best AI model for each request. Instead of manually choosing a model, let Alvin analyze your prompt and route to the optimal model for quality, speed, and cost.

How Alvin Works

When you send a message with Alvin routing enabled:

  1. Prompt Analysis: Alvin analyzes your message to understand the task
  2. Model Matching: Selects the best model based on capabilities
  3. Cost Optimization: Balances quality with cost efficiency
  4. Request Routing: Sends your request to the selected model
  5. Attribution: Shows which model was used in the response

Routing Factors

Alvin considers multiple factors when selecting a model:

Task Type

TaskPreferred Models
Code generationClaude 3.5, GPT-4o
Creative writingGPT-4o, Claude 3
Analysis/reasoningGPT-4, Claude 3.5
Quick questionsGPT-4o-mini, Claude Haiku
Web searchPerplexity Sonar

Complexity

  • Simple queries: Fast, cost-effective models (GPT-4o-mini)
  • Complex reasoning: Advanced models (GPT-4, Claude 3.5)
  • Long context: Models with extended context windows

Cost Efficiency

Alvin optimizes costs by:

  • Using smaller models for simple tasks
  • Reserving premium models for complex requests
  • Monitoring token usage and context length

Model Attribution

Every response shows which model Alvin selected:

Model: gpt-4o-mini • Tokens: 245 • 0.3s

This transparency helps you understand routing decisions and costs.

Overriding Alvin

While Alvin provides excellent default routing, you can override it:

Manual Model Selection

  1. Click the Model dropdown in chat settings
  2. Select a specific model
  3. All subsequent messages use that model
  4. Click Use Alvin to return to automatic routing

When to Override

Consider manual selection when:

  • You need a specific model's capabilities
  • Testing model performance comparisons
  • Working with specialized tasks
  • Debugging or troubleshooting

Cost Savings

Alvin typically saves 30-50% on API costs compared to always using premium models:

ScenarioWithout AlvinWith AlvinSavings
Simple Q&AGPT-4 ($0.03)GPT-4o-mini ($0.002)93%
Code reviewGPT-4 ($0.03)Claude Haiku ($0.005)83%
Complex analysisGPT-4 ($0.03)GPT-4 ($0.03)0%

Routing Transparency

You can see Alvin's routing decisions:

  1. Response header: Shows selected model
  2. Analytics: View routing patterns over time
  3. Cost dashboard: Track savings from intelligent routing

Best Practices

  1. Trust the routing: Alvin is optimized for quality and cost
  2. Use descriptive prompts: Clear prompts help Alvin route accurately
  3. Review analytics: Understand your routing patterns
  4. Override sparingly: Only when you have specific requirements

API Usage

When using the API, Alvin routing is available by specifying the alvin model:

curl -X POST https://api.elyxir.ai/v1/chat/completions \
  -H "Authorization: Bearer elyxir_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "alvin",
    "messages": [{"role": "user", "content": "Write a Python function to sort a list"}]
  }'
Alvin Intelligent Routing | elyxir