Skip to content

About

Universal local AI proxy — multi-key rotation, smart free routing, and streaming for any OpenAI-compatible coding agent (OpenCode, Grok Build, Codex, Claude Code, and more).

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Free Router

Universal local AI proxy — multi-key rotation, quota control, analytics, and smart free routing for any OpenAI-compatible coding agent (OpenCode, Grok Build, Codex, Antigravity, Claude Code, Cline, Continue, Cursor, and more).

Free Router is a self-hosted proxy that sits between your coding agent and a fleet of free / cheap AI providers. It exposes a single OpenAI-compatible /v1 endpoint (http://127.0.0.1:8787/v1) and transparently:

  • Rotates API keys across many accounts per provider, with per-key cooldowns.
  • Routes requests through a configurable fallback chain (OpenRouter → Gemini → Zen → ZenMux → FreeModel → LLM7 → Workers AI → Featherless → iamHC).
  • Recovers from transient failures (5xx / network blips) without freezing a provider for 24h — single-key free providers stay usable.
  • Streams tokens as they are generated (no buffering before the first token).
  • Syncs config to OpenCode and Grok Build, and works with any client that supports an OpenAI-compatible base URL.
  • Drives real browser sessions (ChatGPT, Gemini) via an embedded Electron browser — no API key needed.

Features

Capability Notes
Multi-provider routing Sequential failover across 9 providers out of the box
Multi-key rotation Per-provider key pools with cooldown & quota awareness
Smart cooldowns Soft cooldown for transient errors; hard cooldown only for genuine quota exhaustion
Streaming First token is sent to the client immediately
Model registry Enable/disable, reorder, set default / compaction / small models
Vision sub-agent Routes images to a vision model when the target model lacks vision
Browser sessions Experimental — drive ChatGPT / Gemini through logged-in browser tabs (no API key). Currently broken, see Known limitations.
Analytics SQLite-backed dashboard, requests, key usage, events
Agent integrations One-click OpenCode + Grok Build sync; universal /v1 for everything else

Known limitations

  • Browser proxy is currently not working. The "Browser Sessions" feature (driving ChatGPT / Gemini through the embedded Electron webview) is experimental and is broken in this release — requests fail with errors such as Browser session not started or Failed to open a new tab. Use the API-key providers (OpenRouter, Gemini, Zen, ZenMux, FreeModel, LLM7, Workers AI, Featherless, iamHC) instead; they are fully functional. Browser sessions will be fixed in a future update. Track progress / report details in Issues.
  • The proxy binds to 127.0.0.1 (localhost) only. Do not expose it on 0.0.0.0 without a reverse proxy + auth.
  • state-*.json, settings.json, and *.sqlite are local runtime data and are git-ignored.

Architecture

┌──────────────┐    http://127.0.0.1:8787/v1     ┌─────────────────┐
│ Coding Agent │ ───────────────────────────────▶ │  Free Router    │
│ (OpenCode,   │   OpenAI-compatible chat/completions │  (Node proxy) │
│  Grok, Codex,│                                    │  + Electron UI │
│  Claude…)    │ ◀─────────────────────────────── │                │
└──────────────┘   streamed responses              └────────┬───────┘
                                                             │  routes / failover
                  ┌──────────────────────────────────────────┼─────────────────────────┐
                  ▼            ▼            ▼           ▼            ▼          ▼
              OpenRouter    Gemini        Zen       ZenMux     FreeModel    LLM7   Workers AI …
  • src/index.js — HTTP server, admin API, request routing.
  • src/router.js — failover / provider-selection logic.
  • src/key_pool.js — per-provider key rotation + cooldown policy.
  • src/model_registry.js — model catalog, OpenCode/Grok config generation.
  • src/providers/ — OpenRouter-compatible, Gemini, and browser providers.
  • electron/ — desktop shell (tray, embedded browser, webview bridge).
  • frontend/ — React/Vite dashboard (keys, models, dashboard, browser sessions).

Quick Start (Desktop)

  1. Download Free Router Setup 1.0.0.exe from the Releases page and install.
  2. Open Free Router, go to API Keys, and paste keys for the providers you want.
  3. On the Settings page, click Sync OpenCode config (or Sync Grok config), or just point any agent at http://127.0.0.1:8787/v1.
  4. In your agent, set the model to e.g. fusion/tencent/hy3 or fusion/mimo-v2.5.

Note: The Browser Sessions tab (ChatGPT / Gemini via embedded browser) is currently non-functional — see Known limitations. Use the API-key providers, which work.


Quick Start (From Source)

Prerequisites

  • Node.js ≥ 20
  • A terminal (PowerShell / bash)

Backend + UI (dev)

# Install root + frontend deps
npm install
npm --prefix frontend install

# Configure your keys
cp settings.example.json settings.json
#   edit settings.json and paste your provider API keys

# Run the proxy (port 8787)
npm start
# or with hot reload: npm run dev

# In a second terminal, run the dashboard (Vite on :5173)
npm run frontend:dev

# Build the desktop app
npm run app:build:win      # Windows NSIS installer -> release/

Configure via environment variables

Instead of (or in addition to) settings.json, you can use a .env file. See .env.example for every supported variable (e.g. OPENROUTER_KEYS_JSON, ZEN_KEYS_JSON, GEMINI_API_KEY, WORKERSAI_ACCOUNT_ID).


Using Free Router with any coding agent

Free Router is a standard OpenAI-compatible API. For agents without a dedicated sync button, set:

Setting Value
Base URL http://127.0.0.1:8787/v1
API Key anything (e.g. free-local)
Model fusion/tencent/hy3, fusion/mimo-v2.5, fusion/z-ai/glm-5.2, …

OpenCode

On the Settings page click Sync OpenCode config — it writes ~/.config/opencode/opencode.jsonc. The default model is set automatically.

Grok Build / Grok CLI

Click Sync Grok config — it injects [model.*] entries into ~/.grok/config.toml while leaving your Grok login default intact. Switch with /model.

Codex / Antigravity / Claude Code / Cline / Continue / Cursor

Point the agent's OpenAI-compatible base URL at http://127.0.0.1:8787/v1 with any placeholder key. No extra setup required.


Default models

Model ID Provider Notes
fusion/tencent/hy3 OpenRouter Default model
fusion/mimo-v2.5 Zen Free MiMo v2.5
fusion/z-ai/glm-5.2 ZenMux GLM 5.2
fusion/gemini-3.5-flash Gemini Vision + reasoning
fusion/gpt-5.5 FreeModel
fusion/workersai-glm-5.2 Workers AI
fusion/iamhc-glm-5.2 iamHC GLM 5.2
fusion/iamhc-minimax-m3 iamHC MiniMax M3

Add, enable/disable, and reorder models from the Models page.


Configuration reference

Router chain

router.default_route (in settings.json) controls failover order:

"default_route": ["openrouter", "gemini", "zen", "zenmux", "freemodel", "llm7", "workersai", "featherless", "iamhc"]

Cooldown policy

  • Soft cooldown (soft_cooldown_ms, default 15000): applied on transient 5xx / network errors. Does not block key selection — keeps single-key free providers alive.
  • Hard cooldown (cooldown_ms, default 86400000 = 24h): applied only after repeated genuine exhaustion (quota / 429 storm). Even then, the router still allows the last key through rather than returning a permanent 503.

Providers

Each provider supports keys, base_url, model_id, supports_images, daily_token_limit, max_retries, cooldown_ms, soft_cooldown_ms, state_file, api_style (openrouter-compatible | gemini). See settings.example.json.


Project layout

openrouter-key-pool-proxy/
├── src/                 # Node proxy (router, key pool, providers, registry)
├── electron/            # Desktop shell + embedded browser sessions
├── frontend/           # React/Vite dashboard
├── models.json          # Default model/provider catalog
├── settings.example.json
├── .env.example
└── README.md

Security

  • Never commit settings.json or .env — they contain real API keys. They are git-ignored by default.
  • The proxy binds to 127.0.0.1 (localhost) only. Do not expose it on 0.0.0.0 without a reverse proxy + auth.
  • See SECURITY.md for reporting vulnerabilities.

Roadmap

  • Dedicated one-click config generators for Codex / Claude Code / Antigravity.
  • Per-model latency-aware routing (replace static default_route with live scoring).
  • Automatic provider model discovery on first run.

License

MIT © Free Router contributors.

About

Universal local AI proxy — multi-key rotation, smart free routing, and streaming for any OpenAI-compatible coding agent (OpenCode, Grok Build, Codex, Claude Code, and more).

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages