CLIProxyAPI

CLIProxyAPI is a local server that turns CLI subscriptions and OAuth accounts into a regular HTTP API compatible with OpenAI, Gemini and Claude. The idea is simple: you can have several Codex, Claude Code, Gemini CLI, Antigravity, Kimi or Grok Build accounts, and applications and libraries can only talk to familiar APIs. CLIProxyAPI stands between them, accepts a request in one format, translates it into the required format of the provider and sends a response back.

The project is written in Go, distributed under the MIT license and delivered as a single binary program with no dependencies. Authorization is performed via OAuth directly from the command line, tokens are stored in the `~/.cli-proxy-api` directory, so re-login is only required after access has expired or been revoked.

Main features:

- Chat Completions, Responses, Claude Messages and Gemini API endpoints;
- streaming and regular responses, function calls, input images;
- several accounts of one provider with balancing in a circle;
- automatic switching to another account in case of an error or quota exhaustion;
- own API keys for clients, separate from provider credentials;
- connecting third-party OpenAI-compatible services through configuration;
- control panel and Management API for editing settings without restarting;
- Go SDK for embedding proxies into your applications.

Gemini (including Antigravity and Gemini CLI), OpenAI Codex, Claude Code, xAI Grok, Kimi, GitHub Copilot, Devin and Meta Muse are supported. The model can be specified with an alias, and different accounts can be marked with a priority, weight, or prefix to direct requests to a specific pool.

Installation involves downloading the archive from the releases page, unpacking and running the binary. Inside the archive there is already `config.example.yaml`, which needs to be copied to `config.yaml` and edited. The minimum configuration is enough for the server to run on port 8317 and accept requests with a local key:

config-version: 8

server:
  host: "127.0.0.1"
  port: 8317

management:
  secret-key: "change-me"

access:
  api-keys:
    - "local-dev-key"

Then you log in to the required accounts. Each provider has its own flag, and the browser opens automatically:

cli-proxy-api --codex-login
cli-proxy-api --claude-login
cli-proxy-api --antigravity-login
cli-proxy-api --kimi-login
cli-proxy-api --xai-login
cli-proxy-api --copilot-login

After login, the server is started with a normal call without flags and listens for `http://127.0.0.1:8317`. A list of available models can be obtained by querying `/v1/models`. Checking through a regular HTTP client looks like this:

curl http://127.0.0.1:8317/v1/chat/completions \
  -H "Authorization: Bearer local-dev-key" \
  -H "Content-Type: application/json" \
  -d "{\"model\":\"gpt-6.1-sol\",\"messages\":[{\"role\":\"user\",\"content\":\"Привет\"}]}"

The most interesting scenario is to connect existing tools to the proxy. Claude Code just needs to be sent to a local address:

export ANTHROPIC_BASE_URL=http://127.0.0.1:8317
export ANTHROPIC_AUTH_TOKEN=local-dev-key
claude

On Windows, `set` is used instead of `export`, the syntax of other variables is the same.

Any OpenAI client, including the official Python SDK, also works without changes to the code if you change the base address:

from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:8317/v1",
    api_key="local-dev-key",
)

response = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "Привет"}],
)

print(response.choices[0].message.content)

For OpenCode, the proxy connects as its own OpenAI-compatible provider. It is enough to describe it in global or project `opencode.json` and pass the local key through an environment variable:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "cliproxyapi": {
      "name": "CLIProxyAPI",
      "env": ["CLIPROXYAPI_KEY"],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "http://127.0.0.1:8317/v1"
      },
      "models": {
        "gpt-6.1-sol": {
          "name": "GPT-6.1 Sol"
        }
      }
    }
  }
}
export CLIPROXYAPI_KEY=local-dev-key
opencode

After launch, the model is selected via `/models`, and by default it can be fixed with the line `"model": "cliproxyapi/gpt-6.1-sol"`. Model names are taken from the `/v1/models` response and listed in `models` manually, because for the native provider OpenCode does not load the directory automatically. For Claude models going through the OpenAI-compatible route, it is worth adding `"compatibility": { "cacheFormat": "anthropic" }`, otherwise OpenCode will not place prompt caching points. The configuration is picked up without restarting, so the new account or model in the proxy appears in OpenCode immediately after saving the file.

For Gemini clients use `/v1beta`, for Anthropic-compatible clients use `/v1/messages`. The proxy decides which transport and which account to choose, and knows how to keep a session on one account so as not to lose the cache of prompts.

With multiple subscriptions, balancing occurs in a circle by default. In the configuration, you can enable weighted distribution, first account filling mode, session linking, repetitions on other credentials, and cooling down delays after errors. To monitor the status, there is a Management API and a built-in web panel, and the configuration specifies the access key to them.

The project is actively developing: at the time of publication, the repository has more than 59 thousand stars, and a whole ecosystem of graphical shells and panels for macOS, Windows and Linux has grown around it. There is a separate desktop client EasyCLIProxyAPI, which provides a graphical configuration interface and an icon in the system tray. For those who want to embed a proxy into their own application, there is a Go SDK with support for their own executors and protocol translators.

Separately, it is worth mentioning the risks. Using OAuth access outside of the official client may violate the providers' terms of service, and accounts may be subject to restrictions. It makes sense to launch a proxy only with your own credentials, bind it to `127.0.0.1` and close it with a key if it can be accessed over the network. This is a tool for conveniently combining your own subscriptions, and not a way to bypass payment.

Documentation:

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

GitHub:

https://github.com/router-for-me/CLIProxyAPI

EasyCLIProxyAPI:

https://github.com/router-for-me/EasyCLIProxyAPI