Use Claude Code CLI, VS Code, JetBrains ACP, or chat bots through your own Anthropic-compatible proxy.
Free Claude Code routes Anthropic Messages API traffic from Claude Code to NVIDIA NIM, OpenRouter, DeepSeek, or Ollama Cloud — with round-robin API key rotation for rate-limit resilience. It keeps Claude Code's client-side protocol stable while letting you choose free or paid models.
Deployment & Setup · Providers · Key Rotation · Clients · Development
- Drop-in proxy for Claude Code's Anthropic API calls.
- Four cloud providers: NVIDIA NIM, OpenRouter, DeepSeek, and Ollama Cloud.
- Round-robin key rotation: distribute requests across multiple API keys per provider.
- Per-model routing: send Opus, Sonnet, Haiku, and fallback traffic to different providers.
- Native model picker: Claude Code's
/modelcommand discovers all available models. - Streaming, tool use, reasoning/thinking block handling, and local request optimizations.
- Optional Discord or Telegram bot wrapper for remote coding sessions.
- Optional voice-note transcription through local Whisper or NVIDIA NIM.
- Render-ready: Dockerfile and
render.yamlincluded for one-click cloud deploy.
We highly recommend deploying Free Claude Code using systemd for maximum stability, 24/7 uptime, and seamless background execution. This setup runs completely in user-space (no root required for the proxy).
Install uv (the lightning-fast Python package manager) and Python 3.14:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.bashrc
# Install Python 3.14 via uv
uv python install 3.14Clone the repository and set up your environment variables:
git clone https://github.com/technicalboy2023/free-claude-code.git
cd free-claude-code
cp .env.example .envEdit your .env file to set your provider API keys and authentication token:
nano .envEnsure you set ANTHROPIC_AUTH_TOKEN="your_secure_password" and at least one provider key (e.g., NVIDIA_NIM_API_KEY).
Before setting up auto-start, verify that the server runs correctly:
uv run uvicorn server:app --host 0.0.0.0 --port 8082If it starts without errors, press CTRL+C to stop it and proceed to the next step.
To keep the proxy running permanently in the background and auto-start on PC reboot, create a user-level systemd service:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/free-claude-code.servicePaste the following configuration (replace /home/yourusername with your actual home directory path):
[Unit]
Description=Free Claude Code Proxy Server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=/home/yourusername/Desktop/my project/free-claude-code
ExecStart=/home/yourusername/.local/bin/uv run uvicorn server:app --host 0.0.0.0 --port 8082
Restart=always
RestartSec=5
Environment=PATH=/home/yourusername/.local/bin:/usr/local/bin:/usr/bin:/bin
# Logging
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=default.targetEnable and start the service:
systemctl --user daemon-reload
systemctl --user enable --now free-claude-code.service
# (Optional) Allow the service to run even when you are not logged in:
loginctl enable-linger $USERCheck Status & Logs:
# Check if the service is running
systemctl --user status free-claude-code.service
# View live proxy logs
journalctl --user -u free-claude-code.service -fStop / Start / Restart Service:
systemctl --user stop free-claude-code.service
systemctl --user start free-claude-code.service
systemctl --user restart free-claude-code.serviceHow to Update to the Latest Code: Whenever a new update is released, you can seamlessly update without breaking the setup:
cd ~/free-claude-code
git pull
uv sync --frozen
systemctl --user restart free-claude-code.serviceTo make your server fully autonomous, we have provided two scripts to automate daily updates and log cleanup.
The auto_update.sh script checks GitHub for updates, pulls new code, syncs dependencies, and restarts the proxy automatically.
Make it executable and add it to your crontab to run daily (e.g., at 3:00 PM):
chmod +x auto_update.sh
(crontab -l 2>/dev/null; echo "0 15 * * * $PWD/auto_update.sh") | crontab -To prevent your server.log from growing indefinitely, use the provided logrotate.conf.example.
- Edit
logrotate.conf.exampleand update the paths and username to match your setup. - Copy it to the system logrotate directory:
sudo cp logrotate.conf.example /etc/logrotate.d/free-claude-code
sudo chown root:root /etc/logrotate.d/free-claude-code
sudo chmod 644 /etc/logrotate.d/free-claude-codeThis will compress old logs weekly and keep only the last 4 weeks.
How to switch models: To change your AI model, you only need to edit the MODEL variable in your .env file (or your Render Environment Variables). The router will automatically detect the change. You do not need to edit any other files. Just make sure the corresponding provider's API key is also set.
Model values must use this format:
provider_id/model/name
MODEL is the fallback. MODEL_OPUS, MODEL_SONNET, and MODEL_HAIKU override routing for requests that Claude Code sends for those tiers.
NVIDIA NIM
Get a key at build.nvidia.com/settings/api-keys.
NVIDIA_NIM_API_KEY="nvapi-your-key"
MODEL="nvidia_nim/meta/llama-3.1-8b-instruct"Popular models:
nvidia_nim/meta/llama-3.1-8b-instructnvidia_nim/z-ai/glm5nvidia_nim/moonshotai/kimi-k2.5nvidia_nim/minimaxai/minimax-m2.5
Browse models at build.nvidia.com.
OpenRouter
Get a key at openrouter.ai/keys.
OPENROUTER_API_KEY="sk-or-your-key"
MODEL="open_router/stepfun/step-3.5-flash:free"Browse all models or free models.
DeepSeek
Get a key at platform.deepseek.com/api_keys.
DEEPSEEK_API_KEY="your-deepseek-key"
MODEL="deepseek/deepseek-chat"This provider uses DeepSeek's Anthropic-compatible endpoint, not the OpenAI chat-completions endpoint.
Ollama Cloud
Get a key at ollama.com.
OLLAMA_API_KEY="your-ollama-key"
MODEL="ollama/llama3.3"This provider uses Ollama's OpenAI-compatible endpoint.
Mix providers by model tier
Each tier can use a different provider:
NVIDIA_NIM_API_KEY="nvapi-your-key"
OPENROUTER_API_KEY="sk-or-your-key"
MODEL_OPUS="nvidia_nim/moonshotai/kimi-k2.5"
MODEL_SONNET="open_router/deepseek/deepseek-r1-0528:free"
MODEL_HAIKU="deepseek/deepseek-chat"
MODEL="nvidia_nim/meta/llama-3.1-8b-instruct"Distribute requests across multiple API keys to avoid per-key rate limits. Set comma-separated keys in .env:
# Single key (default)
NVIDIA_NIM_API_KEY="nvapi-key1"
# Multiple keys — requests cycle through each key in order
NVIDIA_NIM_API_KEY="nvapi-key1,nvapi-key2,nvapi-key3"
OPENROUTER_API_KEY="sk-or-v1-key1,sk-or-v1-key2"
DEEPSEEK_API_KEY="sk-ds-key1,sk-ds-key2"
OLLAMA_API_KEY="key1,key2"How it works:
- Each provider creates a thread-safe
KeyRotatoron startup. - Every request rotates to the next key in round-robin order.
- Keys are deduplicated and whitespace-trimmed automatically.
- Single-key setups work exactly as before — no config change needed.
On your local machine (Windows/Mac), configure the Claude Code CLI to route traffic to your new VPS:
claude config set customBaseUrl http://<YOUR_VPS_PUBLIC_IP>:8082
claude config set customApiKey your_secure_passwordNow, simply type claude in your local terminal.
Open Settings, search for claude-code.environmentVariables, choose Edit in settings.json, and add:
"claudeCode.environmentVariables": [
{ "name": "ANTHROPIC_BASE_URL", "value": "http://<YOUR_VPS_PUBLIC_IP>:8082" },
{ "name": "ANTHROPIC_AUTH_TOKEN", "value": "your_secure_password" }
]Reload the extension. If the extension shows a login screen, choose the Anthropic Console path once; the local proxy still handles model traffic after the environment variables are active.
Edit the installed Claude ACP config:
- Windows:
C:\Users\%USERNAME%\AppData\Roaming\JetBrains\acp-agents\installed.json - Linux/macOS:
~/.jetbrains/acp.json
Set the environment for acp.registry.claude-acp:
"env": {
"ANTHROPIC_BASE_URL": "http://<YOUR_VPS_PUBLIC_IP>:8082",
"ANTHROPIC_AUTH_TOKEN": "your_secure_password"
}Restart the IDE after changing the file.
Claude Code 2.1.126 or later reads this proxy's /v1/models endpoint when ANTHROPIC_BASE_URL points at the proxy. Start Claude Code normally, run /model, and choose any discovered provider model.
The proxy lists models for configured provider keys. Picker-safe IDs are routed back to the real provider/model automatically, so no .env edit or separate launcher script is needed after startup.
Each provider model also has a (no thinking) picker variant. Use it when a model does not support Claude Code thinking or fails with adaptive-thinking requests.
The bot wrapper runs Claude Code sessions remotely, streams progress, supports reply-based conversation branches, and can stop or clear tasks.
Discord minimum config:
MESSAGING_PLATFORM="discord"
DISCORD_BOT_TOKEN="your-discord-bot-token"
ALLOWED_DISCORD_CHANNELS="123456789"
CLAUDE_WORKSPACE="./agent_workspace"
ALLOWED_DIR="C:/Users/yourname/projects"Create the bot in the Discord Developer Portal, enable Message Content Intent, and invite it with read/send/history permissions.
Telegram minimum config:
MESSAGING_PLATFORM="telegram"
TELEGRAM_BOT_TOKEN="123456789:ABC..."
ALLOWED_TELEGRAM_USER_ID="your-user-id"
CLAUDE_WORKSPACE="./agent_workspace"
ALLOWED_DIR="C:/Users/yourname/projects"Get a token from @BotFather and your user ID from @userinfobot.
Useful commands:
/stopcancels a task; reply to a task message to stop only that branch./clearresets sessions; reply to clear one branch./statsshows session state.
Voice notes work on Discord and Telegram. Choose one backend:
uv sync --extra voice_local
uv sync --extra voice
uv sync --extra voice --extra voice_localVOICE_NOTE_ENABLED=true
WHISPER_DEVICE="cpu" # cpu | cuda | nvidia_nim
WHISPER_MODEL="base"
HF_TOKEN=""Use WHISPER_DEVICE="nvidia_nim" with the voice extra and NVIDIA_NIM_API_KEY for NVIDIA-hosted transcription.
.env.example is the canonical list of variables. The sections below are the ones most users change.
MODEL="nvidia_nim/meta/llama-3.1-8b-instruct"
MODEL_OPUS=
MODEL_SONNET=
MODEL_HAIKU=
ENABLE_MODEL_THINKING=true
ENABLE_OPUS_THINKING=
ENABLE_SONNET_THINKING=
ENABLE_HAIKU_THINKING=Blank per-tier values inherit the fallback. Blank thinking overrides inherit ENABLE_MODEL_THINKING.
# Single key or comma-separated for round-robin rotation
NVIDIA_NIM_API_KEY=""
OPENROUTER_API_KEY=""
DEEPSEEK_API_KEY=""
OLLAMA_API_KEY=""Proxy settings are per provider:
NVIDIA_NIM_PROXY=""
OPENROUTER_PROXY=""
OLLAMA_PROXY=""PROVIDER_RATE_LIMIT=1
PROVIDER_RATE_WINDOW=3
PROVIDER_MAX_CONCURRENCY=5
HTTP_READ_TIMEOUT=300
HTTP_WRITE_TIMEOUT=10
HTTP_CONNECT_TIMEOUT=10Use lower limits for free hosted providers; higher concurrency is fine when you have multiple API keys in rotation.
ANTHROPIC_AUTH_TOKEN=
LOG_RAW_API_PAYLOADS=false
LOG_RAW_SSE_EVENTS=false
LOG_API_ERROR_TRACEBACKS=false
LOG_RAW_MESSAGING_CONTENT=false
LOG_RAW_CLI_DIAGNOSTICS=false
LOG_MESSAGING_ERROR_DETAILS=falseRaw logging flags can expose prompts, tool arguments, paths, and model output. Keep them off unless you are debugging locally.
ENABLE_WEB_SERVER_TOOLS=true
WEB_FETCH_ALLOWED_SCHEMES=http,https
WEB_FETCH_ALLOW_PRIVATE_NETWORKS=falseThese tools perform outbound HTTP from the proxy. Keep private-network access disabled unless you are in a controlled environment.
Claude Code CLI / VS Code / JetBrains
│
│ Anthropic Messages API
▼
Free Claude Code Proxy (:8082)
│
│ round-robin key rotation
│ provider-specific request/stream adapter
▼
NVIDIA NIM / OpenRouter / DeepSeek / Ollama Cloud
Important pieces:
- FastAPI exposes Anthropic-compatible routes:
/v1/messages,/v1/messages/count_tokens,/v1/models. - Model routing resolves Claude model names to
MODEL_OPUS,MODEL_SONNET,MODEL_HAIKU, orMODEL. - NIM uses OpenAI chat streaming translated into Anthropic SSE.
- OpenRouter and DeepSeek use Anthropic Messages style transports.
- Key rotation cycles API keys per-request across all configured keys for each provider.
- The proxy normalizes thinking blocks, tool calls, token usage metadata, and provider errors into the shape Claude Code expects.
- Request optimizations answer trivial Claude Code probes locally to save latency and quota.
Update to the latest commit first. Then check:
ANTHROPIC_BASE_URLishttp://localhost:8082, nothttp://localhost:8082/v1.- The proxy is returning Server-Sent Events for
/v1/messages. server.logcontains no upstream 400/500 response before the malformed-response error.
Errors like incomplete chunked read, server disconnected, or a peer closing the body usually come from the upstream provider or gateway. Reduce concurrency, raise timeouts, or retry later.
Tool support is model and provider dependent. Some OpenAI-compatible models emit malformed tool-call deltas, omit tool names, or return tool calls as plain text. Try another model or provider before assuming the proxy is broken.
Confirm the extension environment variables are set, then reload the extension or restart VS Code. The browser login flow may still appear once; the local proxy is used when ANTHROPIC_BASE_URL is active in the extension process.
free-claude-code/
├── server.py # ASGI entry point (reads $PORT for Render)
├── Dockerfile # Production container (Debian + uv + Python 3.14)
├── render.yaml # Render Blueprint for one-click deploy
├── api/ # FastAPI routes, service layer, routing, optimizations
├── core/ # Shared Anthropic protocol helpers and SSE utilities
├── providers/ # Provider transports, registry, key rotation, rate limiting
│ └── key_rotator.py # Thread-safe round-robin key rotation
├── messaging/ # Discord/Telegram adapters, sessions, voice
├── cli/ # Package entry points and Claude process management
├── config/ # Settings, provider catalog, logging
└── tests/ # Unit and contract tests (1159 tests)
uv run ruff format
uv run ruff check
uv run ty check
uv run pytestRun them in that order before pushing. CI enforces the same checks.
pyproject.toml installs:
free-claude-code: starts the proxy with configured host and port.fcc-init: creates the user config template at~/.config/free-claude-code/.env.
- Add OpenAI-compatible providers by extending
OpenAIChatTransport. - Add Anthropic Messages providers by extending
AnthropicMessagesTransport. - Register provider metadata in
config.provider_catalogand factory wiring inproviders.registry. - Add messaging platforms by implementing the
MessagingPlatforminterface inmessaging/.
- Report bugs and feature requests in Issues.
- Keep changes small and covered by focused tests.
- Run the full check sequence before opening a pull request.
MIT License. See LICENSE for details.

