TokenRouter Overview - Intelligent AI Routing Platform
What is TokenRouter?
Section titled “What is TokenRouter?”TokenRouter is an intelligent LLM routing platform that sits between your application and AI providers. It automatically selects the best provider and model for each request based on your optimization preferences, routing rules, and firewall policies.
Key Benefits
Section titled “Key Benefits”- Cost Savings: Automatically route to the most cost-effective provider for each request
- Improved Reliability: Failover to backup providers when your primary choice is unavailable
- Better Performance: Route based on latency, quality, or balanced optimization
- Simplified Integration: One API for multiple providers (OpenAI, Anthropic, Google, Mistral, DeepSeek, Meta)
- Enhanced Security: Built-in firewall rules and content filtering
- Full Observability: Track usage, costs, and performance across all providers
How It Works
Section titled “How It Works”TokenRouter wraps the OpenAI Responses API with an intelligent routing layer:
- Send a Request: Your application sends a standard request to
https://api.tokenrouter.io/v1/responses - Intelligent Routing: TokenRouter analyzes your request, routing rules, and provider availability
- Provider Selection: The optimal provider is selected based on your routing mode (cost, quality, latency, or balance)
- Firewall Enforcement: Your firewall rules are applied to filter or modify the request
- Response Delivery: A fully OpenAI-compatible response is returned to your application
The router monitors live provider pricing, historical latency, and your account limits to ensure you always get the best trade-off for each request.
Routing Strategies
Section titled “Routing Strategies”You can adjust the routing strategy per-request, define deterministic rules in the console, or force a specific provider when compliance requires it.
Use automatic routing modes for intelligent provider selection:
const response = await client.responses.create({ model: 'auto:balance', // Balanced optimization input: 'Explain quantum computing'});Available modes:
auto:balance- Balanced trade-offauto:cost- Minimize costsauto:quality- Maximize qualityauto:latency- Minimize latency
Request a specific model with a routing mode:
const response = await client.responses.create({ model: 'gpt-4o:quality', // Use GPT-4o with quality optimization input: 'Write a detailed business plan'});Or just specify the model:
const response = await client.responses.create({ model: 'claude-3-7-sonnet-latest', input: 'Analyze this code'});Define rules in the console for deterministic routing:
- Route all requests containing “code” to Anthropic
- Route requests under 100 tokens to cost-optimized providers
- Force specific models for compliance requirements
- Set fallback providers for high availability
Supported Providers
Section titled “Supported Providers”TokenRouter supports the following AI providers:
| Provider | Models | Special Features |
|---|---|---|
| OpenAI | GPT-4o, GPT-4 Turbo, GPT-3.5 Turbo | Function calling, vision, structured outputs |
| Anthropic | Claude 3.7 Sonnet, Claude 3 Opus, Claude 3 Haiku | Extended context, vision, tool use |
| Gemini 1.5 Pro, Gemini 1.5 Flash | Multimodal, long context | |
| Mistral | Mistral Large, Mistral Medium | European hosting, function calling |
| DeepSeek | DeepSeek V3 | Cost-effective, code generation |
| Meta | Llama 4 (special access required) | Open weights, on-premises options |
OpenAI Compatibility
Section titled “OpenAI Compatibility”TokenRouter is designed as a drop-in replacement for the OpenAI API. If you’re currently using OpenAI, migrating to TokenRouter requires minimal changes:
import OpenAI from 'openai';
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY});
const response = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello!' }]});import Tokenrouter from 'tokenrouter';
const client = new Tokenrouter({ apiKey: process.env.TOKENROUTER_API_KEY});
const response = await client.responses.create({ model: 'auto:balance', // Intelligent routing input: 'Hello!'});The key differences:
- Use TokenRouter API key instead of OpenAI key
- Use
responses.create()instead ofchat.completions.create() - Use
inputparameter instead ofmessagesarray (simplified interface) - Access to multiple providers through routing modes
Next Steps
Section titled “Next Steps”Get Started
Section titled “Get Started”- Create an account at TokenRouter
- Generate an API key in the console
- Add your provider keys (OpenAI, Anthropic, etc.)
- Install the SDK and make your first request
Learn More
Section titled “Learn More”- Authentication - API key management
- Quickstart Guide - Get up and running in 5 minutes
- Provider Keys - How to add and manage provider credentials
- Routing Rules - Advanced routing configuration