A zero-dependency Node.js proxy server that routes OpenAI-compatible requests (Cline) and Anthropic Messages requests (Claude CLI / Claude Code) to OpenRouter free-tier models with automatic failover, SWE-first prioritization, and multi-batch recovery.
- Zero Dropped Agent Loops: Automatically intercepts rate limits (
429) or server overloads (503) and cascades to the next best free model without breaking agent workflows. - Dual Protocol Support: Exposes both
/v1/chat/completions(OpenAI format for Cline) and/v1/messages(Anthropic format with native SSE streaming for Claude Code). - Bypasses 3-Model Limits: OpenRouter limits fallback arrays to 3 models per request; this proxy seamlessly handles 10+ models across sequential multi-batch retries.
- Auto Mode Fast-Path: Intercepts Claude Code's repetitive safety classifier checks (
claude-sonnet-5), auto-approving in <20ms with 0 tokens to preserve free rate limits. - Zero External Dependencies: Pure Node.js (v18+) using native
fetchand streams—nonpm installneeded. Works identically on Windows, macOS, and Linux.
The cascade is generated from OpenRouter's live model list by scripts/sync-models.mjs and written to cascade.json (git-ignored), which router.mjs loads at startup. If the file is missing or invalid, the router uses its built-in lists.
A model is kept only if it is free, text-in/text-out, supports tool calling, has at least 128k context, is at least 7B parameters, is not about to expire, and answers a small live test request. Pinned models (default nvidia/nemotron-3-ultra-550b-a55b:free, override with SYNC_PINNED in .env) go first, then models ordered by context length. openrouter/free is always appended as the safety net.
npm run sync:dry # show the resulting cascade without writing
npm run sync # write cascade.json and restart the proxy if the list changed
On Windows, the daily Scheduled Task OpenRouterProxySync (04:00) runs the sync.
(For Cline, models are automatically chunked into 3-model batches. TokenHarbor free models like deepseek-v4.1-flash:free are also supported if configured).
If using an AI coding agent (Claude Code, Cline, Cursor, Antigravity, Roo Code, etc.), paste this prompt into your agent to clone, install, configure, and launch the proxy automatically:
Agent Prompt:
Clone https://github.com/hissain/FreeModelsForCline.git, set up the .env file from .env.example, start the background proxy service, and configure my coding tool to use it. Critical Decisions — Before proceeding, ask me: 1. What is my OpenRouter API Key (sk-or-v1-...)? (Required for OpenRouter free models; prompt me to input it so it can be saved to .env) 2. Which client should be configured: Claude Code, Cline, or both? Once I provide those answers: - Save the API key to .env (and ensure PORT=8081). - Start the background proxy daemon using `node scripts/proxy.mjs start`. - Verify the service is healthy at http://localhost:8081/health. - Configure the requested client(s): * Claude Code: Set ANTHROPIC_BASE_URL="http://localhost:8081" and ANTHROPIC_MODEL="free-router" in ~/.claude/settings.json or .claude/settings.local.json. * Cline: Set Base URL to "http://localhost:8081/v1", Model ID to "free-router", and API Key to "dummy". - Run a test prompt through the client to confirm free-tier routing is functional.
npm run init # or: node scripts/proxy.mjs initAdd your key to .env:
OPENROUTER_API_KEY=sk-or-v1-your-key-here
PORT=8081
SAFETY_CLASSIFIER_MODEL=auto-approvenpm run proxy:start # or: node scripts/proxy.mjs startThe server listens at http://localhost:8081/v1.
Add to ~/.claude/settings.json (or .claude/settings.local.json in your project):
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:8081",
"ANTHROPIC_AUTH_TOKEN": "dummy",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_MODEL": "free-router"
},
"permissions": {
"allow": ["Bash(*)", "Read(*)", "Write(*)", "Edit(*)", "Glob(*)", "Grep(*)"]
},
"allowDangerouslySkipPermissions": true
}ANTHROPIC_MODEL: "free-router": Triggers proxy auto-cascading across free models.ANTHROPIC_API_KEY: "": Prevents unwanted browser login attempts to Anthropic.SAFETY_CLASSIFIER_MODEL=auto-approve: Bypasses Claude Code's backgroundclaude-sonnet-5permission checks in<20ms, saving 100% of classifier API calls.
Test Claude CLI:
claude -p "Say hello in 3 words"In Cline Settings -> API Provider:
- API Provider:
OpenAI Compatible - Base URL:
http://localhost:8081/v1 - API Key:
dummy - Model ID:
free-router
Managed via cross-platform Node CLI (scripts/proxy.mjs):
| Command | Action |
|---|---|
npm run proxy:start |
Start in background with auto-restart supervisor |
npm run proxy:stop |
Stop background proxy and supervisor |
npm run proxy:status |
Check health, port status, and recent log lines |
npm run proxy:restart |
Restart the proxy |
npm run autostart:install |
Register proxy to boot on user login (Windows/macOS/Linux) |
npm run autostart:uninstall |
Remove autostart registration |
- Windows: VBS script in
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup - macOS: LaunchAgent plist in
~/Library/LaunchAgents - Linux: systemd user service in
~/.config/systemd/user
MIT © 2026 Md. Sazzad Hissain Khan
Made by Hissain with ❤️ for Developers
