Skip to content

jeffnash/CLIProxyAPI

 
 

Repository files navigation

CLIProxyAPI Plus

English | Chinese

This is the Plus version of CLIProxyAPI, adding support for third-party providers on top of the mainline project.

Note

Upstream reference (for baseline behavior/docs): https://github.com/luispater/CLIProxyAPI/blob/main/README.md


Important

This is a fork (read me first)

This repository is a fork/derivative build of CLIProxyAPI.

Motivation: make it easy to use your existing AI subscriptions (Claude Code, Codex, Gemini, Copilot, etc.) from any OpenAI-compatible client/SDK and from multiple coding CLIs — locally or hosted — without rewriting tooling.

What’s different from upstream (and why):

  • More provider adapters & auth flows (Copilot, Grok, etc.) — so you can route requests through the subscription/provider you already pay for, using a consistent OpenAI-compatible API surface.
  • Chutes provider support (API key + dynamic model discovery) — optionally expose Chutes-hosted models via OpenAI-compatible endpoints using CHUTES_API_KEY / CHUTES_BASE_URL. Supports configurable retry logic with CHUTES_MAX_RETRIES (default: 4) and CHUTES_RETRY_BACKOFF (default: 5,15,30,60 seconds).
  • Passthru model routing (env + YAML) — declare arbitrary model IDs (e.g. glm-4.7) that are forwarded to external upstream APIs (OpenAI-compatible / Anthropic / Responses), with per-route API keys/headers; ideal for hosted deployments (Railway) via PASSTHRU_MODELS_JSON.
  • Railway-first deployment path (scripts/railway_start.sh, docs/RAILWAY_GUIDE.md) — to make it dead simple to spin up a personal, always-on CLIProxyAPI instance you can call from anywhere.
    • Log in locally (interactive browser/device flows), then package credentials into AUTH_BUNDLE via scripts/auth_bundle.sh and restore them in a remote environment.
  • Hosted-friendly credential transfer (AUTH_BUNDLE/AUTH_ZIP_URL) — avoids having to manually copy lots of files/secrets around when deploying.
  • Compatibility emphasis (including Responses-style clients) — so tools expecting OpenAI-compatible endpoints “just work” with minimal configuration.
  • One config, many tools — point Claude Code / Codex CLI / Gemini-compatible clients / IDE extensions at one base URL and let the proxy handle provider routing and account management.

If you only want the upstream behavior/features, compare against the original upstream repository and docs.

Recommended companion tools / related forks:

  • Patch-22 (recommended): a tiny apply_patch safety net binary/script for when a model tries to run apply_patch as a shell command: github.com/jeffnash/patch-22.
  • Letta Code (jeffnash fork): github.com/jeffnash/letta-code is wired up to route main model calls through a hosted jeffnash/CLIProxyAPI instance.
  • Letta (jeffnash fork): github.com/jeffnash/letta includes scripts to deploy the Letta server to Railway and pairs well with this proxy.

All third-party provider support is maintained by community contributors; CLIProxyAPI does not provide technical support. Please contact the corresponding community maintainer if you need assistance.

It now also supports OpenAI Codex (GPT models) and Claude Code via OAuth.

The Plus release stays in lockstep with the mainline features.

Differences from the Mainline

z.ai

This project is sponsored by Z.ai, supporting us with their GLM CODING PLAN.

GLM CODING PLAN is a subscription service designed for AI coding, starting at just $3/month. It provides access to their flagship GLM-4.7 model across 10+ popular AI coding tools (Claude Code, Cline, Roo Code, etc.), offering developers top-tier, fast, and stable coding experiences.

Get 10% OFF GLM CODING PLAN:https://z.ai/subscribe?ic=8JVLJQFSKB


PackyCode Thanks to PackyCode for sponsoring this project! PackyCode is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more. PackyCode provides special discounts for our software users: register using this link and enter the "cliproxyapi" promo code during recharge to get 10% off.
Cubence Thanks to Cubence for sponsoring this project! Cubence is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more. Cubence provides special discounts for our software users: register using this link and enter the "CLIPROXYAPI" promo code during recharge to get 10% off.

Fork-Focused Quickstart

This fork is primarily optimized for:

  • Using OAuth/subscription logins (Codex / Claude Code / Gemini / Copilot / etc.) behind an OpenAI-compatible base URL
  • Hosting your own personal instance (especially on Railway) so you can call it from anywhere

Key docs:

  • End-user Railway deployment: docs/RAILWAY_GUIDE.md
  • Railway Copilot Electron shim: docs/RAILWAY_ELECTRON_SHIM.md
  • Railway scripts reference: scripts/README_RAILWAY.md
  • SDK usage (embed the proxy in Go): docs/sdk-usage.md
  • SDK advanced: docs/sdk-advanced.md
  • SDK access/auth: docs/sdk-access.md
  • Credential watching: docs/sdk-watcher.md

Provider & config matrix (fork-specific):

Topic Where Notes
Provider login commands (Gemini / Claude / Codex / Copilot / Grok / Qwen / iFlow / Antigravity / Vertex) docs/RAILWAY_GUIDE.md See the “Local Authentication” table for exact --*-login flags.
Grok support docs/RAILWAY_GUIDE.md Uses --grok-login (SSO cookies flow).
Copilot support docs/RAILWAY_GUIDE.md Uses --copilot-login (device code flow).
Railway env vars (auth transfer) scripts/README_RAILWAY.md AUTH_BUNDLE or AUTH_ZIP_URL, plus API_KEY_1, optional AUTH_DIR_NAME, FORCE_BUILD.
Copilot initiator behavior internal/runtime/executor/copilot_headers.go Default is X-Initiator: agent for Copilot requests. Trusted internal callers can override via request header force-copilot-initiator: user (used by Copilot Hot Takes).
Copilot config keys (YAML) internal/config/config.go Look under CopilotKey config + related fields for the authoritative schema (initiator flags + header profile selection).
Copilot header behavior internal/runtime/executor/copilot_headers.go Implementation for request header shaping / agent-call behavior + optional header profile emulation.
Copilot model registry internal/registry/copilot_models.go How Copilot models are enumerated/aliased.
Force Copilot routing sdk/api/handlers/handlers.go / sdk/cliproxy/auth/conductor.go Use copilot-<model> to explicitly route to Copilot even if the model isn't registered; bypasses client model support filtering.
Force Codex routing sdk/api/handlers/handlers.go / sdk/cliproxy/auth/conductor.go Use codex-<model> to explicitly route to Codex; sets forced_provider=true to bypass client model support filtering.
Force Kimi routing sdk/api/handlers/handlers.go / sdk/cliproxy/auth/conductor.go Use kimi-<model> to explicitly route to Kimi; sets forced_provider=true to bypass client model support filtering.
Force iFlow routing sdk/api/handlers/handlers.go / sdk/cliproxy/auth/conductor.go Use iflow-<model> to explicitly route to iFlow; sets forced_provider=true to bypass client model support filtering.
Copilot Hot Takes internal/cmd/copilot_hot_takes.go / docs/RAILWAY_GUIDE.md Optional background job controlled by COPILOT_HOT_TAKES_INTERVAL_MINS and COPILOT_HOT_TAKES_MODEL.
Grok config schema internal/config/config.go GrokKey and GrokConfig sections define available knobs.
Chutes support (env + YAML) internal/config/config.go / docs/RAILWAY_GUIDE.md Env vars: CHUTES_API_KEY, CHUTES_BASE_URL, CHUTES_MODELS, CHUTES_MODELS_EXCLUDE, CHUTES_PRIORITY, CHUTES_TEE_PREFERENCE, CHUTES_PROXY_URL, CHUTES_MAX_RETRIES. YAML: chutes section.
Force Chutes routing sdk/api/handlers/handlers.go / sdk/cliproxy/auth/conductor.go Use chutes-<model> to explicitly route to Chutes; sets forced_provider=true to bypass client model support filtering.
Chutes model aliasing + fallbacks internal/registry/chutes_models.go Generates chutes- aliases for explicit routing + contains conservative fallback models.
Chutes executor internal/runtime/executor/chutes_executor.go Implements OpenAI-compatible chat completions + streams, model fetch/cache, and token counting.
Chutes priority filtering sdk/cliproxy/service.go / sdk/cliproxy/chutes_priority_hook.go CHUTES_PRIORITY=fallback hides non-prefixed Chutes IDs when another provider has the same model ID; chutes- aliases remain routable.
OAuth excluded models internal/config/config.go oauth-excluded-models config lets you disable models per provider.
OpenAI-compat upstreams internal/config/config.go openai-compatibility for routing to other OpenAI-compatible providers.
Routing behavior internal/config/config.go routing config controls credential selection/failover.

Copilot initiator (fork default)

This fork defaults Copilot requests to X-Initiator: agent.

Trusted internal callers can override the initiator with the request header:

  • force-copilot-initiator: user|agent

This is used for opt-in background jobs (see Copilot Hot Takes in docs/RAILWAY_GUIDE.md).

Chutes config (quick explainer)

Chutes is an optional OpenAI-compatible upstream. You can route to it either explicitly (recommended) or by exposing non-prefixed IDs.

  • Explicit routing: set model: "chutes-<model>" (works as long as Chutes is configured).
  • Env vars:
    • CHUTES_API_KEY (required), CHUTES_BASE_URL (optional)
    • CHUTES_MODELS / CHUTES_MODELS_EXCLUDE (optional allow/block lists)
    • CHUTES_PRIORITY (fallback default hides non-prefixed IDs when another provider offers the same ID; primary exposes them)
    • CHUTES_TEE_PREFERENCE (prefer default), CHUTES_PROXY_URL (optional)
    • CHUTES_MAX_RETRIES (default 4; set 0 to disable) — retries intermittent 429s

If you want the baseline upstream documentation/behavior, start here: https://github.com/luispater/CLIProxyAPI/blob/main/README.md

If you want more details (and exact env vars), see docs/RAILWAY_GUIDE.md and scripts/README_RAILWAY.md.


Note: this fork’s docs intentionally focus on fork-specific behavior; the upstream README is the best reference for the baseline project.


Hosted instance goals:

  • Log in locally once, then transfer credentials via scripts/auth_bundle.sh (AUTH_BUNDLE) to your host.
  • Point your clients/tools at your hosted base URL and keep using the same API key.

Capabilities (Fork)

  • OpenAI-compatible API endpoints for chat + tools (plus provider routing)
  • OAuth/cookie login flows for multiple providers and multi-account load balancing
  • Streaming + non-streaming responses, multimodal inputs (where supported)
  • Compatibility targets: OpenAI-compatible clients/SDKs (including Responses-style clients) + coding CLIs

Getting Started

CLIProxyAPI Guides: https://help.router-for.me/

Management API

see MANAGEMENT_API.md

Who is with us?

Those projects are based on CLIProxyAPI:

Native macOS menu bar app to use your Claude Code & ChatGPT subscriptions with AI coding tools - no API keys needed

Browser-based tool to translate SRT subtitles using your Gemini subscription via CLIProxyAPI with automatic validation/error correction - no API keys needed

  • Added GitHub Copilot support (OAuth login), provided by em4go
  • Added Kiro (AWS CodeWhisperer) support (OAuth login), provided by fuko2935, Ravens2121

CLI wrapper for instant switching between multiple Claude accounts and alternative models (Gemini, Codex, Antigravity) via CLIProxyAPI OAuth - no API keys needed

Native macOS GUI for managing CLIProxyAPI: configure providers, model mappings, and endpoints via OAuth - no API keys needed.

Note

If you developed a project based on CLIProxyAPI, please open a PR to add it to this list.

Sponsor

z.ai

This project is sponsored by Z.ai, supporting us with their GLM CODING PLAN.

GLM CODING PLAN is a subscription service designed for AI coding, starting at just $10/month. It provides access to their flagship GLM-4.7 & (GLM-5 Only Available for Pro Users)model across 10+ popular AI coding tools (Claude Code, Cline, Roo Code, etc.), offering developers top-tier, fast, and stable coding experiences.

Get 10% OFF GLM CODING PLAN:https://z.ai/subscribe?ic=8JVLJQFSKB


PackyCode Thanks to PackyCode for sponsoring this project! PackyCode is a reliable and efficient API relay service provider, offering relay services for Claude Code, Codex, Gemini, and more. PackyCode provides special discounts for our software users: register using this link and enter the "cliproxyapi" promo code during recharge to get 10% off.
AICodeMirror Thanks to AICodeMirror for sponsoring this project! AICodeMirror provides official high-stability relay services for Claude Code / Codex / Gemini CLI, with enterprise-grade concurrency, fast invoicing, and 24/7 dedicated technical support. Claude Code / Codex / Gemini official channels at 38% / 2% / 9% of original price, with extra discounts on top-ups! AICodeMirror offers special benefits for CLIProxyAPI users: register via this link to enjoy 20% off your first top-up, and enterprise customers can get up to 25% off!

Who is with us?

Those projects are based on CLIProxyAPI:

Native macOS menu bar app to use your Claude Code & ChatGPT subscriptions with AI coding tools - no API keys needed

Browser-based tool to translate SRT subtitles using your Gemini subscription via CLIProxyAPI with automatic validation/error correction - no API keys needed

CLI wrapper for instant switching between multiple Claude accounts and alternative models (Gemini, Codex, Antigravity) via CLIProxyAPI OAuth - no API keys needed

Native macOS GUI for managing CLIProxyAPI: configure providers, model mappings, and endpoints via OAuth - no API keys needed.

Native macOS menu bar app that unifies Claude, Gemini, OpenAI, Qwen, and Antigravity subscriptions with real-time quota tracking and smart auto-failover for AI coding tools like Claude Code, OpenCode, and Droid - no API keys needed.

Native macOS SwiftUI app for managing CLI AI sessions (Codex, Claude Code, Gemini CLI) with unified provider management, Git review, project organization, global search, and terminal integration. Integrates CLIProxyAPI to provide OAuth authentication for Codex, Claude, Gemini, Antigravity, and Qwen Code, with built-in and third-party provider rerouting through a single proxy endpoint - no API keys needed for OAuth providers.

Windows-native CLIProxyAPI fork with TUI, system tray, and multi-provider OAuth for AI coding tools - no API keys needed.

VSCode extension for quick switching between Claude Code models, featuring integrated CLIProxyAPI as its backend with automatic background lifecycle management.

Windows desktop app built with Tauri + React for monitoring AI coding assistant quotas via CLIProxyAPI. Track usage across Gemini, Claude, OpenAI Codex, and Antigravity accounts with real-time dashboard, system tray integration, and one-click proxy control - no API keys needed.

A lightweight web admin panel for CLIProxyAPI with health checks, resource monitoring, real-time logs, auto-update, request statistics and pricing display. Supports one-click installation and systemd service.

A Windows tray application implemented using PowerShell scripts, without relying on any third-party libraries. The main features include: automatic creation of shortcuts, silent running, password management, channel switching (Main / Plus), and automatic downloading and updating.

霖君 is a cross-platform desktop application for managing AI programming assistants, supporting macOS, Windows, and Linux systems. Unified management of Claude Code, Gemini CLI, OpenAI Codex, Qwen Code, and other AI coding tools, with local proxy for multi-account quota tracking and one-click configuration.

A modern web-based management dashboard for CLIProxyAPI built with Next.js, React, and PostgreSQL. Features real-time log streaming, structured configuration editing, API key management, OAuth provider integration for Claude/Gemini/Codex, usage analytics, container management, and config sync with OpenCode via companion plugin - no manual YAML editing needed.

Browser extension for one-stop management of New API-compatible relay site accounts, featuring balance and usage dashboards, auto check-in, one-click key export to common apps, in-page API availability testing, and channel/model sync and redirection. It integrates with CLIProxyAPI through the Management API for one-click provider import and config sync.

Shadow AI is an AI assistant tool designed specifically for restricted environments. It provides a stealthy operation mode without windows or traces, and enables cross-device AI Q&A interaction and control via the local area network ( LAN). Essentially, it is an automated collaboration layer of "screen/audio capture + AI inference + low-friction delivery", helping users to immersively use AI assistants across applications on controlled devices or in restricted environments.

Note

If you developed a project based on CLIProxyAPI, please open a PR to add it to this list.

All third-party provider support is maintained by community contributors; CLIProxyAPI does not provide technical support. Please contact the corresponding community maintainer if you need assistance.

If you need to submit any non-third-party provider changes, please open them against the mainline repository.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Never stop coding. Smart routing to FREE & low-cost AI models with automatic fallback.

OmniRoute is an AI gateway for multi-provider LLMs: an OpenAI-compatible endpoint with smart routing, load balancing, retries, and fallbacks. Add policies, rate limits, caching, and observability for reliable, cost-aware inference.

Note

If you have developed a port of CLIProxyAPI or a project inspired by it, please open a PR to add it to this list.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Wrap Gemini CLI, ChatGPT Codex, Claude Code, Qwen Code, iFlow as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini 2.5 Pro, GPT 5, Claude, Qwen model through API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 99.2%
  • Other 0.8%