Use the official Claude Code CLI entirely for free (or with custom OpenAI-compatible API providers) by redirecting its API requests through a local translating proxy server.
Claude Code communicates with Anthropic's servers via the ANTHROPIC_BASE_URL API endpoint. This tool starts a local server on http://localhost:3000 which acts as a compatibility layer. By updating Claude Code's configuration:
- All Claude Code requests are routed to the local proxy server.
- The proxy server automatically translates Anthropic API calls (both streaming and non-streaming) into standard OpenAI Chat Completions calls.
- The proxy routes these translated requests to:
- Your Custom Provider: Defined in
custom_key.json(e.g. OpenRouter, Aerolink, or any OpenAI-compatible API endpoint). - Free Key Pool: If no custom provider is configured, it auto-rotates through a public repository of free keys (
alistaitsacle/free-llm-api-keys), dynamically disabling rate-limited or broken keys so your session remains uninterrupted.
- Your Custom Provider: Defined in
- The tool presents a model selector menu and boots Claude Code with your chosen model.
- Free Tier Keys Rotation: Automatically fetches, tests, rotates, and caches working API keys from public sources.
- Custom OpenAI-Compatible API Support: Seamlessly route Claude Code to OpenRouter, local models (LM Studio, Ollama), or other private APIs.
- Cross-Platform CLI: Written in both Node.js and Python. Run it with a single command on Windows, macOS, and Linux.
- PowerShell Script Fallback: For Windows users who prefer launching via manual shell scripts.
- Automatic Environment Configuration: Sets the appropriate variables and configuration files automatically.
First, ensure you have the official Claude Code CLI installed globally:
npm install -g @anthropic-ai/claude-codeThen install Claude Code Free using either Python (pip) or Node.js (npm):
In the repository directory, run:
npm install -g .This registers the global CLI command claude-free.
In the repository directory, run:
pip install .This registers the global CLI command claude-free via python entry points.
Simply run:
claude-freeThis will:
- Verify Claude Code is installed.
- Spin up the Node.js proxy server in the background.
- Automatically update
~/.claude/settings.jsonto route throughhttp://localhost:3000/v1with a dummy key. - Display a menu to select your desired AI model.
- Launch the interactive
claudeshell. - Automatically close the background proxy server when you exit the Claude session.
If you prefer not to use the global CLI, you can launch using PowerShell (Windows only):
- Start the proxy server:
node src/proxy.js
- In a separate terminal, launch the PowerShell script:
./scripts/start.ps1
To use your own API provider instead of the free rotation pool, create a file named custom_key.json in ~/.claude/custom_key.json (or the folder where you run the proxy):
{
"CUSTOM_API_KEY": "your_api_key_here",
"CUSTOM_BASE_URL": "https://api.openrouter.ai/v1",
"Model-name": "claude-3-5-sonnet-latest"
}Note: The proxy will automatically fall back to the free rotating key pool if custom_key.json is missing or contains "your_api_key_here".
To configure your system variables to run Claude Code natively with OpenRouter without running the proxy server, run:
./scripts/setup_openrouter.ps1Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.