CLI2API is self-hosted and uses accounts you already have. If you would rather not run it, the sponsor offers a hosted gateway.
| Sponsor | What it is | Who it is for | Link |
|---|---|---|---|
| CaiAI | A prepaid OpenAI-compatible API gateway. One key covers clients such as Claude Code, Codex, OpenCode, Cherry Studio, and TRAE, routes models including GPT, Grok, GLM, and Kimi, and includes usage, key limits, and billing. | Teams that want model access without bringing their own logins | caiaiu.com |
CLI2API manages your own accounts on a local gateway. CaiAI manages hosted keys, routing, and billing.
You need Docker and an upstream account you control. Use Docker Desktop on macOS / Windows; Windows must use Linux containers.
git clone https://github.com/caigee-cmd/cli2api.git
cd cli2api
./scripts/start.sh # Windows: scripts\start.ps1- Save the administrator key printed on first start.
- Open
http://127.0.0.1:3010, sign in, and add an account under Accounts. - Create a client key under API keys, then pick a model and test it under Access.
Point any OpenAI-compatible client at:
Base URL: http://127.0.0.1:3010/v1
API Key: <the client key you just created>
Model IDs come from Access or /v1/models. Routing is automatic and prefers the same account for later turns. Environment variables, account pinning, and managed updates are in the deployment guide.
Connect Qoder (Global / CN), WorkBuddy (Global / CN), and Trae CN Work. Devin, Command Code, and Huawei Cloud CodeArts (码道) are experimental and not a production promise.
The Go gateway handles authentication, routing, and request logging. PAT-backed Qoder accounts talk to the upstream in-process. Qoder accounts that still use the legacy CLI credential keep one Node process and HOME each. Other providers use in-process adapters, so no full CLI starts per request.
- Three APIs: Chat Completions, Responses, and Anthropic Messages, plus model listing. Streaming and function tools included.
- Many accounts: round-robin, weighted round-robin, fill-first, and opt-in same-provider earliest-expiry-first (FEFO). Automatic selection, session affinity, concurrency limits, cooldowns, and failover stay on.
- One console: accounts, models, client keys, proxies, quotas, and request logs.
- Docker: account data persists. An optional host updater downloads, confirms, and rolls back from the console.
Qoder CN, WorkBuddy, and Trae are implemented; live-account acceptance is still pending. Kimi Code CN and CodeArts have single-account end-to-end acceptance. CodeArts quota-exhaustion failover, and live upgrade / rollback, are still pending.
Readiness and quota sit on the account card. Access copies the Base URL and runs a quick check. WorkBuddy, QwenWork, and Qoder can check in from the card; automatic check-in is off by default, and its schedule lives under System → Automatic check-in. Live-account check-in acceptance is still pending.
Choose Earliest expiry first (FEFO) under System → Account routing strategy, or send {"routing_strategy":"fefo"} to PATCH /api/system/settings. Round-robin stays the default.
Accounts are ranked only inside one provider, by the nearest credit package that can still be spent. Missing dates are never guessed, and those accounts join only after every dated account is unavailable. Exhausted, cooling, and concurrency-saturated accounts still drop out first. Only WorkBuddy personal accounts currently expose a per-package expiry.
- Bring your own accounts. CLI2API does not supply accounts, quotas, or an official API.
- Compatibility is not full parity. Messages / Responses keep no server-side conversation and run no upstream-specific tools.
- Images depend on the upstream and the model, exposed as
supports_images. See the deployment guide. - Routing one model ID across upstreams follows system settings, key grants, and region.
- An upstream protocol change can break compatibility. Request logs omit prompt and completion bodies by default.
The default listen address is 127.0.0.1:3010. Do not expose it directly to the public internet. Administrator keys run the console; client keys only reach /v1/*. Keep keys, credential exports, and database backups to yourself. Report security issues privately, as SECURITY.md describes.
Discussion is in the Telegram group. In China you can also scan the personal WeChat QR below. Bugs and feature requests go to GitHub Issues. Docs and code: CONTRIBUTING.md. History: CHANGELOG.md.
Thanks to open-source projects including workbuddy2api, CLIProxyAPI, and sub2api for ideas and inspiration.
MIT. Follow each upstream platform's terms when using its accounts.
