Skip to content

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 โ€‹

  1. Visit openrouter.ai
  2. Sign up for an account
  3. Go to the API Keys section
  4. Generate a new API key

2. Configure CCProxy โ€‹

Set the following environment variables:

bash
export PROVIDER=openrouter
export OPENROUTER_API_KEY=sk-or-v1-your_openrouter_api_key_here

3. Optional Configuration โ€‹

bash
# 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:

  1. Verify Tool Support: Ensure the model supports function calling
  2. Check Availability: Model availability changes frequently
  3. Review Capabilities: Different models excel at different tasks
  4. 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 โ€‹

bash
# .env file
PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-v1-your_api_key_here

Top Performance Setup - Qwen3 235B โ€‹

bash
# 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=16384

Ultra-Fast Setup - Kimi K2 โ€‹

bash
# 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=8192

Real-Time Data Setup - Grok โ€‹

bash
# 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=8192

High-Performance Setup โ€‹

bash
# 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=4096

Quality-Focused Setup โ€‹

bash
# 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=16384

Cost-Optimized Setup โ€‹

bash
# 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=8192

Usage with Claude Code โ€‹

Once configured, use Claude Code normally:

bash
# 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:

bash
# 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-2

Model Fallbacks โ€‹

Configure automatic failover between models:

bash
# Set primary and fallback models
export OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
export OPENROUTER_FALLBACK=openai/gpt-4o

Usage Tracking โ€‹

OpenRouter provides detailed analytics:

bash
# Add tracking headers
export OPENROUTER_SITE_URL=https://yourapp.com
export OPENROUTER_SITE_NAME="Your App Name"

Custom Headers โ€‹

bash
# Add custom tracking
export OPENROUTER_X_TITLE="Your Request Title"

Performance Tips โ€‹

1. Choose the Right Model โ€‹

bash
# 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-instruct

2. Optimize Token Usage โ€‹

bash
# Reduce max tokens for faster responses
export OPENROUTER_MAX_TOKENS=1024

# Use appropriate context length
export OPENROUTER_MAX_TOKENS=4096

3. Monitor Usage โ€‹

Check your usage and costs:

bash
# View OpenRouter dashboard
curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  https://openrouter.ai/api/v1/auth/key

Troubleshooting โ€‹

Rate Limit Errors โ€‹

json
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error"
  }
}

Solution: OpenRouter has generous rate limits. Wait and retry, or check your usage.

Authentication Errors โ€‹

json
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error"
  }
}

Solution: Verify your API key is correct and has sufficient credits.

Model Not Available โ€‹

json
{
  "error": {
    "message": "Model not found or not available",
    "type": "invalid_request_error"
  }
}

Solution: Check the OpenRouter models page for available models.

Insufficient Credits โ€‹

json
{
  "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 responses
  • openai/o1-preview - Advanced reasoning

For Ultra-Fast Speed โ€‹

  • moonshotai/kimi-k2-instruct - Fastest inference with 128K context
  • openai/gpt-4o-mini - Fast and cost-effective
  • anthropic/claude-3-haiku - Ultra-fast responses

For Real-Time Data โ€‹

  • xai/grok-beta - Real-time web access and current information
  • xai/grok-2 - Enhanced reasoning with real-time data

For General Use โ€‹

  • anthropic/claude-3.5-sonnet - Best all-around performance
  • openai/gpt-4o - Strong reasoning and tool use

For Cost โ€‹

  • qwen/qwen-2.5-72b-instruct - Great quality-to-cost ratio
  • meta-llama/llama-3.1-405b-instruct - Open source powerhouse

For Coding โ€‹

  • deepseek/deepseek-coder - Specialized for code
  • anthropic/claude-3.5-sonnet - Excellent code understanding
  • qwen/qwen-3-235b-a22b-2507 - Superior problem solving

Monitoring โ€‹

Monitor your OpenRouter usage:

bash
# Check CCProxy logs
tail -f ccproxy.log

# Check OpenRouter status
curl http://localhost:3456/status

# View usage analytics on OpenRouter dashboard

Next 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