caigee-cmd/cli2api
Self-hosted OpenAI-compatible API for Qoder CLI login,workbuddy, with SQLite multi-account routing
CLI2API – Turn Your Own Login Sessions into a Local OpenAI‑compatible API
What it is – CLI2API is a self‑hosted gateway that lets you expose the chat‑completion, response, and Anthropic‑style endpoints of OpenAI‑compatible APIs locally. It works by taking the authentication you already have for services such as Qoder, WorkBuddy, Trae, and (experimentally) Devin and Command Code, and routing OpenAI‑style requests to those back‑ends.
Why it matters – Many developers have personal accounts on these Chinese‑market AI platforms but lack a standard OpenAI‑compatible endpoint to plug into existing tools (e.g., VS Code extensions, LangChain, CLI clients). CLI2API bridges that gap without exposing your credentials to the public internet.
Core Features
- OpenAI‑compatible endpoints – Supports
chat/completions,responses, Anthropicmessages, model listing, streaming responses, and function‑tool calling. - Multi‑account scheduling – Automatic account selection, session stickiness, concurrency limits, cooldowns, and fail‑over.
- Web console – Manage accounts, models, client API keys, proxy settings, view usage quotas and request logs.
- Docker‑first deployment – Persistent account data, optional host‑side updater for in‑place upgrades/rollbacks.
- Provider adapters –
- Qoder (both international and domestic editions) – runs as an isolated Node process per account.
- WorkBuddy, Trae, Devin, Command Code – run as Go adapters inside the gateway process.
Quick Start (Linux/macOS/Windows with Docker)
# clone and enter the repo
git clone https://github.com/caigee-cmd/cli2api.git
cd cli2api
# start the stack (Linux/macOS) – on Windows use scripts\start.ps1
./scripts/start.sh
- Note the admin key printed in the first log line.
- Open
http://127.0.0.1:3010in a browser, log in with the admin key, and add your provider accounts under Accounts. - Create a client API key under API keys, pick the models you want under Access, and test the connection.
- Point any OpenAI‑compatible client to:
- Base URL:
http://127.0.0.1:3010/v1 - API Key: the client key you just created
- Model IDs are listed on the Access page or via
/v1/models.
- Base URL:
Full deployment instructions, environment variables, and advanced options are in deploy/README.md.
How It Works
- A Go gateway receives every HTTP request, performs authentication, logs the call, and decides which upstream account to use.
- For Qoder each account runs in its own Node process with a dedicated HOME directory, ensuring isolation.
- For the other providers the gateway calls Go‑written adapters directly, avoiding the overhead of spawning a full CLI per request.
- The architecture diagram (see README) shows the flow: client → Go gateway → per‑account runtime → upstream AI service.
When to Use CLI2API
- You have personal accounts on Qoder, WorkBuddy, Trae, etc., and want to use tools that only understand OpenAI’s API.
- You need a local endpoint (e.g., for development, offline testing, or privacy) that does not expose your credentials to the internet.
- You want a single web UI to monitor usage, rotate keys, and switch between multiple provider accounts.
Limitations & Caveats
- Not a public service – It only forwards requests using your upstream accounts; it does not provide any extra quota.
- The compatibility layer is stateless; it does not store conversation history on the server side, nor does it support provider‑specific tools beyond the generic OpenAI function‑call format.
- Image generation depends on the upstream model; WorkBuddy and Trae currently do not support images.
- Cross‑provider model switching is subject to system switches, account permissions, and regional restrictions.
- The project is still awaiting full validation of real accounts for Qoder/WorkBuddy/Trae and the experimental Devin/Command Code integrations.
- By default the API only listens on
127.0.0.1:3010. Exposing it publicly requires additional network hardening.
Security Notes
- Keep the admin key secret – it can modify accounts and system settings.
- Client keys should be treated like normal API tokens; they only grant access to the
/v1/*endpoints. - Request logs omit prompt and response bodies by default, but you can enable them if needed.
- Follow the guidelines in
SECURITY.mdfor reporting vulnerabilities.
Community & Contribution
- Chinese‑language discussion happens on the LINUX DO forum (link in README).
- Issues and feature requests are handled via GitHub Issues.
- Contributions follow the standard fork‑branch‑PR workflow; see
CONTRIBUTING.mdfor details.
License
MIT – you may use, modify, and distribute the software, but you must respect the terms of the upstream AI platforms when using your own accounts.
TL;DR – CLI2API gives you a locally hosted, OpenAI‑compatible API front‑end for your own Qoder/WorkBuddy/Trae (and experimental Devin/Command Code) accounts, managed through a Docker‑based stack and a web console.
Related
- Project
- Project
- Project
- Project
- Project