LLM Router API
One endpoint. Every model. Smart routing. Send a prompt with your constraints and we pick the optimal model, proxy the request, and return the response with cost data.
How It Works
Send request
Messages + constraints + your API keys
Filter models
25 models checked against your constraints
Rank & select
Sorted by cheapest, fastest, or best quality
Proxy request
Sent to provider using YOUR API key
Return response
Content + cost data + model reasoning
Why Use the Router?
Save money
Automatically routes to the cheapest model that meets your quality bar. Real-time pricing data updated weekly.
Stay fast
Set max latency constraints. We pick the fastest qualifying model based on real TTFT benchmarks.
No lock-in
Use YOUR API keys. Switch providers without code changes. One unified API for all providers.
Real-time data
Pricing and benchmark data scraped weekly from provider pages. Always current.
25 models
Anthropic, Google, OpenAI, DeepSeek, xAI, Meta, Alibaba, Mistral, Cohere, Microsoft and more. Every major LLM provider in one API.
Cost transparency
Every response includes exact cost breakdown: input tokens, output tokens, and total cost.
Quick Start
cURL
curl -X POST https://llmversus.com/api/v1/router/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Write a Python function to sort a list"}
],
"constraints": {
"max_input_cost_per_million": 5.0,
"min_arena_elo": 1200,
"prefer": "cheapest"
},
"api_keys": {
"openai": "sk-...",
"anthropic": "sk-ant-..."
}
}'JavaScript / TypeScript
const response = await fetch("https://llmversus.com/api/v1/router/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
messages: [{ role: "user", content: "Write a Python function to sort a list" }],
constraints: {
max_input_cost_per_million: 5.0,
min_arena_elo: 1200,
prefer: "cheapest",
},
api_keys: {
openai: process.env.OPENAI_API_KEY,
anthropic: process.env.ANTHROPIC_API_KEY,
},
}),
});
const data = await response.json();
console.log(data.content); // The LLM response
console.log(data.router.selected); // Which model was chosen
console.log(data.cost_estimate); // Exact cost breakdownPython
import requests, os
resp = requests.post("https://llmversus.com/api/v1/router/chat", json={
"messages": [{"role": "user", "content": "Write a Python function to sort a list"}],
"constraints": {
"max_input_cost_per_million": 5.0,
"min_arena_elo": 1200,
"prefer": "cheapest",
},
"api_keys": {
"openai": os.environ["OPENAI_API_KEY"],
"anthropic": os.environ["ANTHROPIC_API_KEY"],
},
})
data = resp.json()
print(data["content"]) # The LLM response
print(data["router"]["selected"]) # Which model was chosen
print(data["cost_estimate"]) # Exact cost breakdownModel Selection Only
Just want to know which model to use? The /select endpoint returns a recommendation without making any API call. No API keys required.
curl -X POST https://llmversus.com/api/v1/router/select \
-H "Content-Type: application/json" \
-d '{
"constraints": {
"max_input_cost_per_million": 3.0,
"min_arena_elo": 1250,
"require_function_calling": true,
"prefer": "cheapest"
}
}'
// Response:
{
"selected_model": {
"slug": "gpt-4o",
"name": "GPT-4o",
"provider": "OpenAI",
"pricing": { "input_per_million": 2.50, "output_per_million": 10.00 },
"arena_elo": 1260,
"ttft_ms": 230
},
"alternatives": [...],
"reasoning": "Selected GPT-4o (OpenAI) — cheapest at $2.5/M input. 3 models matched..."
}Constraint Reference
| Parameter | Type | Description |
|---|---|---|
max_input_cost_per_million | number | Max input cost in $/million tokens |
max_output_cost_per_million | number | Max output cost in $/million tokens |
min_arena_elo | number | Minimum Arena ELO score (quality floor) |
max_ttft_ms | number | Maximum time-to-first-token in milliseconds |
min_context_window | number | Minimum context window size in tokens |
require_json_mode | boolean | Model must support JSON mode |
require_vision | boolean | Model must support vision/images |
require_function_calling | boolean | Model must support function calling |
require_code_execution | boolean | Model must support code execution |
prefer | "cheapest" | "fastest" | "best_quality" | Ranking preference (default: cheapest) |
exclude_providers | string[] | Provider slugs to exclude |
only_providers | string[] | Only consider these providers |
Pricing
Free
$0/mo
- 100 routed requests/day
- All models & providers
- /select endpoint unlimited
- Community support
Pro
$29/mo
- 10,000 requests/day
- All models & providers
- Priority routing
- Email support
Enterprise
$99/mo
- Unlimited requests
- All models & providers
- Priority routing & support
- Custom constraints
FAQ
Do you store my API keys?
No. Your API keys are passed per-request and used only to proxy that single request to the provider. We never store, log, or cache your keys.
How is the optimal model selected?
The router filters all models by your constraints (cost, quality, speed, capabilities), then ranks them by your preference ("cheapest", "fastest", or "best_quality"). The top-ranked model is selected.
What happens if no model matches my constraints?
You get a 404 response with a suggestion to relax your constraints. The /select endpoint is free and helps you test constraints before sending requests.
How current is the pricing data?
Pricing and benchmark data is scraped from provider pages weekly. The lastVerified date is included in each model's data.
Can I use this without proxying?
Yes. The /api/v1/router/select endpoint returns which model to use without making any API call. No API keys required. Use it to build your own routing logic.
Ready to start routing?
Try the playground or integrate in under 5 minutes.