A Cloudflare Worker that translates between Anthropic's Claude API and OpenAI-compatible APIs, enabling you to use Claude Code with OpenRouter and other OpenAI-compatible providers.
- Local-First: Designed to run locally on your machine for maximum privacy and control.
- Model Override: Force specific models (like Grok, Gemini, etc.) via environment variables without changing Claude Code settings.
- API Key Override: Use a separate OpenRouter API key for the router while keeping your Anthropic key in Claude Code settings.
- Reasoning Support: Full support for OpenRouter's reasoning capabilities (e.g., DeepSeek R1).
# Clone the repository
git clone https://github.com/elusznik/open-claude-router.git
cd open-claude-router
# Install dependencies
npm installCreate a .dev.vars file in the project root to store your secrets. This file is ignored by Git.
# .dev.vars
# Force the router to use this model regardless of what Claude Code requests
MODEL_OVERRIDE="x-ai/grok-4.1-fast"
# Your OpenRouter API Key
OPENROUTER_API_KEY="sk-or-..."We recommend using the detached mode scripts, which automatically configure Claude Code for you.
Start Router & Patch Config:
./start-detached.shThis script will:
- Backup your existing
~/.claude/settings.json. - Update Claude Code to use the local router (
http://localhost:8787). - Start the router in the background.
Stop Router & Restore Config:
./stop-router.shImportant
You MUST use ./stop-router.sh to stop the router. This script restores your original settings.json (Anthropic defaults). If you just kill the process, your Claude Code configuration will remain pointed at localhost.
npm run devThe router will start at http://localhost:8787.
Point Claude Code to your local router. You can leave your Anthropic API key as is (it will be ignored if OPENROUTER_API_KEY is set in .dev.vars).
# Set the base URL to your local router
export ANTHROPIC_BASE_URL="http://localhost:8787"
# (Optional) Set a dummy key if you haven't set one yet
export ANTHROPIC_API_KEY="sk-dummy-key"
# Run Claude Code
claudeYou can force the router to use a specific model by setting MODEL_OVERRIDE in .dev.vars. This is useful because it allows you to keep claude-3-5-sonnet in your Claude Code settings (ensuring compatibility) while actually using a different model backend.
Set OPENROUTER_API_KEY in .dev.vars to use a specific key for OpenRouter requests. This allows you to keep your actual Anthropic key in your global settings if you switch back and forth.
You can also run the router using Docker:
docker-compose up -dMake sure to map your .dev.vars or set environment variables in docker-compose.yml.
Special thanks to these projects that inspired open-claude-router:
MIT