Built entirely with Claude Code - An AI-powered development workflow
A Cloudflare Worker proxy that enables Claude Code to access OpenRouter's diverse model selection. CCR acts as a translation layer between Anthropic's Claude API format and OpenAI-compatible APIs.
This Cloudflare Worker acts as a translation layer between Anthropic's Claude API format and OpenAI-compatible APIs, specifically OpenRouter. It allows Claude Code to access a wide range of models through OpenRouter while maintaining the familiar Claude API interface.
Key Features:
- 🔄 API Translation: Seamlessly converts between Anthropic and OpenAI API formats
- 🌐 OpenRouter Integration: Access to multiple AI models through OpenRouter's unified API
- ⚡ Cloudflare Workers: Fast, globally distributed proxy with minimal latency
- 🎯 Claude Code Compatible: Designed specifically for Claude Code users
Install Claude Code CLI:
npm install -g @anthropic-ai/claude-codeFor more details, see: https://docs.anthropic.com/en/docs/claude-code/setup
Sign up at openrouter.ai and get your API key
# Use either ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN (both work the same way)
ANTHROPIC_BASE_URL="https://ccr.duyet.net" ANTHROPIC_API_KEY="your-openrouter-api-key" claude
ANTHROPIC_BASE_URL="https://ccr.duyet.net" ANTHROPIC_AUTH_TOKEN="your-openrouter-api-key" claude# Use either ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN with custom models
ANTHROPIC_BASE_URL="https://ccr.duyet.net" ANTHROPIC_API_KEY="your-openrouter-api-key" ANTHROPIC_MODEL="moonshotai/kimi-k2:free" ANTHROPIC_SMALL_FAST_MODEL="google/gemini-2.5-flash" claude
ANTHROPIC_BASE_URL="https://ccr.duyet.net" ANTHROPIC_AUTH_TOKEN="your-openrouter-api-key" ANTHROPIC_MODEL="moonshotai/kimi-k2:free" ANTHROPIC_SMALL_FAST_MODEL="google/gemini-2.5-flash" claudeFor permanent setup, add to your shell profile:
export ANTHROPIC_BASE_URL="https://ccr.duyet.net"
# Use either ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN (both work the same way)
export ANTHROPIC_API_KEY="your-openrouter-api-key"
# OR
export ANTHROPIC_AUTH_TOKEN="your-openrouter-api-key"
# Optional: Set default models
export ANTHROPIC_MODEL="moonshotai/kimi-k2:free"
export ANTHROPIC_SMALL_FAST_MODEL="google/gemini-2.5-flash"
# Then simply run:
claudeThat's it! Claude Code will now use OpenRouter's models through the CCR proxy.
-
Add the environment variables to your shell profile:
echo 'export ANTHROPIC_BASE_URL="https://ccr.duyet.net"' >> ~/.bashrc # Use either ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN (both work the same way) echo 'export ANTHROPIC_API_KEY="your-openrouter-api-key"' >> ~/.bashrc # OR echo 'export ANTHROPIC_AUTH_TOKEN="your-openrouter-api-key"' >> ~/.bashrc source ~/.bashrc
-
Start Claude Code:
claude
If you want to deploy your own CCR instance:
# Install Wrangler CLI
npm install -g wrangler
# Clone and deploy
git clone https://github.com/duyet/ccr.git
cd ccr
wrangler deploySet your OpenRouter API key:
wrangler secret put OPENROUTER_API_KEY
# Enter your OpenRouter API key when promptedUpdate wrangler.toml:
[vars]
OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1"CCR automatically handles model mapping:
- OpenRouter Model IDs: Models with
/(likemoonshotai/kimi-k2:free) are passed through directly - Claude Short Names:
haiku,sonnet,opusare mapped to their OpenRouter equivalents - Custom Models: Any model name set via
ANTHROPIC_MODELenvironment variable is used as-is
Claude Code users can override the default model using the ANTHROPIC_MODEL environment variable.
- Use a secure connection
- Keep your API key private
- Only use trusted CCR instances
For testing and development:
# Start local development server
wrangler dev
# Test locally with Claude Code
export ANTHROPIC_BASE_URL="http://localhost:8787"
export ANTHROPIC_API_KEY="your-openrouter-api-key"
claudeAuthentication Error
Error: Invalid API key
- Ensure your OpenRouter API key is set:
wrangler secret put OPENROUTER_API_KEY - Verify the key is valid at OpenRouter
Model Not Found
Error: Model not found
- Check supported models list above
- Verify model is available on OpenRouter
- Use full OpenRouter model ID if needed
Streaming Issues
Error: Connection timeout or malformed events
- Ensure your OpenRouter API key supports streaming
- Check that the model you're using supports streaming responses
Worker Not Responding
- Check deployment status:
wrangler deployments list - View logs:
wrangler tail - Verify your worker domain is correct
- Check the OpenRouter documentation
- View worker logs:
wrangler tail - Create an issue in this repository
- Visit your worker homepage for built-in documentation
- Authentication: Currently uses hardcoded token (will be fixed)
- Error Handling: Basic error responses
- Rate Limiting: Not implemented
- OpenRouter - Get your API key
- Cloudflare Workers - Hosting platform
- Anthropic - Claude models
- Wrangler CLI - Deployment tool
MIT License - see LICENSE file for details.
Built entirely with Claude Code - Showcasing AI-powered development workflow