OpenRouter Provider โ
OpenRouter unlocks the full AI ecosystem by providing access to 100+ different AI models through a single API, including the top-performing Qwen3 235B with its record-breaking AIME25 score of 70.3. As a major supporter of cutting-edge models, OpenRouter offers reliable access to Qwen3 235B, Kimi K2's ultra-fast inference, Grok's real-time data capabilities, alongside Claude, GPT-4, and many others. When combined with Claude Code and CCProxy, OpenRouter becomes the ultimate platform for AI experimentation, allowing you to leverage the most advanced models for each development task.
๐ฏ Why Choose OpenRouter for Claude Code? โ
- ๐ Top performance: Access to Qwen3 235B with AIME25 score of 70.3 (vs GPT-4o's 26.7)
- โก Ultra-fast options: Kimi K2 with 128K context for lightning-fast inference
- ๐ Real-time data: Grok models with current web information access
- ๐ฏ 100+ models: Access to all major AI models through familiar Claude Code interface
- ๐ Model fallbacks: Automatic failover between models for maximum reliability
- ๐ Usage analytics: Detailed tracking and monitoring integrated with CCProxy
- ๐ฐ Cost optimization: Compare and choose the most cost-effective models for each task
- ๐งช Perfect for experimentation: Test different models without changing your Claude Code workflow
- โก Unified API: Single integration for Qwen3, Kimi K2, Grok, Claude 3.5, GPT-4, and more
Setup โ
1. Get an API Key โ
- Visit openrouter.ai
- Sign up for an account
- Go to the API Keys section
- Generate a new API key
2. Configure CCProxy โ
Set the following environment variables:
export PROVIDER=openrouter
export OPENROUTER_API_KEY=sk-or-v1-your_openrouter_api_key_here3. Optional Configuration โ
# Custom model (default: anthropic/claude-3.5-sonnet)
export OPENROUTER_MODEL=moonshotai/kimi-k2-instruct
# Custom max tokens (default: 16384)
export OPENROUTER_MAX_TOKENS=8192
# Custom base URL (default: https://openrouter.ai/api/v1)
export OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
# Site URL for tracking (optional)
export OPENROUTER_SITE_URL=https://yourapp.com
# Site name for tracking (optional)
export OPENROUTER_SITE_NAME="Your App Name"๐ Top Models Available โ
Qwen3 235B A22B 2507 - Leading Performance โ
The current top-performing model on OpenRouter, Qwen3 235B delivers exceptional capabilities:
- ๐ AIME25 Score: 70.3 - Crushing GPT-4o's 26.7 score
- ๐ก Advanced reasoning: State-of-the-art mathematical and logical capabilities
- ๐ Massive scale: 235B parameters with optimized inference
- ๐ Production ready: Reliable performance for demanding applications
Kimi K2 - Ultra-Fast Inference โ
- โก Lightning fast: Optimized for rapid responses
- ๐ 128K context: Handle large documents and codebases
- ๐ฏ Tool calling: Full Claude Code compatibility
- ๐ฐ Cost effective: Great performance-to-price ratio
Grok Models - Real-Time Data โ
- ๐ Real-time access: Current information and web data
- ๐ Dynamic updates: Always up-to-date responses
- ๐ ๏ธ Tool support: Compatible with Claude Code workflows
- ๐ Continuous learning: Incorporates latest information
Available Models โ
OpenRouter provides access to 100+ AI models from leading providers including:
- Qwen - Top-performing Qwen3 235B with record-breaking benchmarks
- Anthropic - Claude series with advanced reasoning
- OpenAI - GPT-4 series and reasoning models
- Moonshot AI - Kimi K2 with ultra-fast inference
- xAI - Grok models with real-time data access
- Meta - Llama models for open-source applications
- Google - Gemini models with multimodal capabilities
- Mistral - European privacy-focused models
- Many others - Including specialized coding and reasoning models
๐ง Critical for Claude Code: You must select models that support tool calling or function calling capabilities, as Claude Code requires these features to operate correctly.
Model Selection Guidelines โ
When choosing models on OpenRouter:
- Verify Tool Support: Ensure the model supports function calling
- Check Availability: Model availability changes frequently
- Review Capabilities: Different models excel at different tasks
- Consider Cost: Pricing varies significantly between models
For current model availability, capabilities, and pricing, visit OpenRouter's official models page.
Pricing โ
OpenRouter offers competitive pricing with transparent costs:
Free Tier โ
- Free credits for new users
- No monthly fees
- Pay-as-you-use pricing
Cost Structure โ
- Competitive per-token pricing across all models
- No minimum spend required
- Volume discounts available
For current, accurate pricing information, visit OpenRouter's official pricing page.
Configuration Examples โ
Basic Setup โ
# .env file
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_hereTop Performance Setup - Qwen3 235B โ
# For the highest performing model (AIME25: 70.3)
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=qwen/qwen-3-235b-a22b-2507
OPENROUTER_MAX_TOKENS=16384Ultra-Fast Setup - Kimi K2 โ
# For ultra-fast inference with large context
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=moonshotai/kimi-k2-instruct
OPENROUTER_MAX_TOKENS=8192Real-Time Data Setup - Grok โ
# For real-time information access
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=xai/grok-beta
OPENROUTER_MAX_TOKENS=8192High-Performance Setup โ
# For speed-focused applications
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=openai/gpt-4o-mini
OPENROUTER_MAX_TOKENS=4096Quality-Focused Setup โ
# For best quality responses
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=anthropic/claude-3-opus
OPENROUTER_MAX_TOKENS=16384Cost-Optimized Setup โ
# For cost-effective usage
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here
OPENROUTER_MODEL=qwen/qwen-2.5-72b-instruct
OPENROUTER_MAX_TOKENS=8192Usage with Claude Code โ
Once configured, use Claude Code normally:
# Set CCProxy as the API endpoint
export ANTHROPIC_BASE_URL=http://localhost:3456
# Claude Code will use CCProxy, no direct Anthropic API key needed
# Use Claude Code
claude "Compare different sorting algorithms"Features โ
โ Supported โ
- Text generation
- Function calling
- Tool use
- Streaming responses
- Vision capabilities (model dependent)
- JSON mode (model dependent)
- Custom temperature/top_p
- Model fallbacks
- Usage tracking
โ ๏ธ Model Dependent โ
- Vision/image input
- Real-time data access
- Code execution
- File uploads
Advanced Features โ
Model Routing Examples โ
Configure intelligent model routing based on task requirements:
# For maximum performance tasks
export OPENROUTER_MODEL=qwen/qwen-3-235b-a22b-2507
export OPENROUTER_FALLBACK=anthropic/claude-3-opus
# For speed-critical applications
export OPENROUTER_MODEL=moonshotai/kimi-k2-instruct
export OPENROUTER_FALLBACK=openai/gpt-4o-mini
# For real-time information needs
export OPENROUTER_MODEL=xai/grok-beta
export OPENROUTER_FALLBACK=xai/grok-2Model Fallbacks โ
Configure automatic failover between models:
# Set primary and fallback models
export OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
export OPENROUTER_FALLBACK=openai/gpt-4oUsage Tracking โ
OpenRouter provides detailed analytics:
# Add tracking headers
export OPENROUTER_SITE_URL=https://yourapp.com
export OPENROUTER_SITE_NAME="Your App Name"Custom Headers โ
# Add custom tracking
export OPENROUTER_X_TITLE="Your Request Title"Performance Tips โ
1. Choose the Right Model โ
# For maximum performance: Use the top-scoring model
export OPENROUTER_MODEL=qwen/qwen-3-235b-a22b-2507
# For speed: Use ultra-fast models
export OPENROUTER_MODEL=moonshotai/kimi-k2-instruct
# For quality: Use larger, more capable models
export OPENROUTER_MODEL=anthropic/claude-3-opus
# For real-time data: Use models with web access
export OPENROUTER_MODEL=xai/grok-beta
# For cost: Use open-source models
export OPENROUTER_MODEL=qwen/qwen-2.5-72b-instruct2. Optimize Token Usage โ
# Reduce max tokens for faster responses
export OPENROUTER_MAX_TOKENS=1024
# Use appropriate context length
export OPENROUTER_MAX_TOKENS=40963. Monitor Usage โ
Check your usage and costs:
# View OpenRouter dashboard
curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \
https://openrouter.ai/api/v1/auth/keyTroubleshooting โ
Rate Limit Errors โ
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error"
}
}Solution: OpenRouter has generous rate limits. Wait and retry, or check your usage.
Authentication Errors โ
{
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}Solution: Verify your API key is correct and has sufficient credits.
Model Not Available โ
{
"error": {
"message": "Model not found or not available",
"type": "invalid_request_error"
}
}Solution: Check the OpenRouter models page for available models.
Insufficient Credits โ
{
"error": {
"message": "Insufficient credits",
"type": "insufficient_quota"
}
}Solution: Add credits to your OpenRouter account.
Model Selection Guide โ
For Top Performance โ
qwen/qwen-3-235b-a22b-2507- #1 Overall - AIME25 score 70.3 (vs GPT-4o's 26.7)anthropic/claude-3-opus- Highest quality responsesopenai/o1-preview- Advanced reasoning
For Ultra-Fast Speed โ
moonshotai/kimi-k2-instruct- Fastest inference with 128K contextopenai/gpt-4o-mini- Fast and cost-effectiveanthropic/claude-3-haiku- Ultra-fast responses
For Real-Time Data โ
xai/grok-beta- Real-time web access and current informationxai/grok-2- Enhanced reasoning with real-time data
For General Use โ
anthropic/claude-3.5-sonnet- Best all-around performanceopenai/gpt-4o- Strong reasoning and tool use
For Cost โ
qwen/qwen-2.5-72b-instruct- Great quality-to-cost ratiometa-llama/llama-3.1-405b-instruct- Open source powerhouse
For Coding โ
deepseek/deepseek-coder- Specialized for codeanthropic/claude-3.5-sonnet- Excellent code understandingqwen/qwen-3-235b-a22b-2507- Superior problem solving
Monitoring โ
Monitor your OpenRouter usage:
# Check CCProxy logs
tail -f ccproxy.log
# Check OpenRouter status
curl http://localhost:3456/status
# View usage analytics on OpenRouter dashboardNext Steps โ
- Explore other providers for comparison and specialized use cases
- Learn about model fallbacks for production reliability
- Set up usage monitoring to optimize model selection and costs
- Try Groq with Kimi K2 for ultra-fast inference alongside OpenRouter