Use QCode with 9router
Add QCode.cc as a custom provider in 9router, a local multi-provider router, for cross-provider fallback and unified management
Use QCode with 9router¶
9router is a local multi-provider AI routing proxy: it runs an OpenAI-compatible service on your own machine (default http://localhost:20128/v1), takes over requests from tools like Claude Code, Cursor, Cline, and Codex, and forwards them to multiple upstream providers according to your rules (including automatic fallback / switching when a quota is exhausted / output compression to save tokens, etc.). Conceptually it's similar to QCode's own CCR — the difference is that 9router runs on your own machine and is managed by you.
For exact features, ports, and UI, refer to the 9router official repo; this article only covers "how to add QCode to it".
When you need it¶
- Connecting to QCode directly is simpler and more stable: if you only use QCode, just point your tool's BASE_URL at
api.qcode.cc— you don't need 9router. - When 9router makes sense: when you want to mix QCode with other providers (subscription plans, free credits, self-hosted, etc.) and need a unified entry point, automatic fallback, cross-provider switching, or token compression, you can register QCode as one of 9router's providers (as the primary or as a fallback layer).
Add QCode as a provider¶
- Start 9router per its docs and open the local console (default
http://localhost:20128). -
Under Providers, add a custom / OpenAI-compatible (Compatible Node) provider:
-
Endpoint / Base URL:
- Chat (GPT family):
https://api.qcode.cc/openai/v1 - Chat (Claude family, if 9router supports Anthropic-protocol nodes):
https://api.qcode.cc/api - Image (optional):
https://api.qcode.cc/qcode-img/v1(see the note below) - In mainland China, swap the domain for
asia.qcode.ccfor lower latency.
- Chat (GPT family):
- API Key: your QCode API Key (starts with
cr_). - Models / aliases: register
claude-opus-4-8,claude-sonnet-4-6,gpt-5.5,gpt-5.4,gpt-5.3-codex, etc. as needed. - Put this QCode provider into your tier / fallback chain (e.g. as the primary, or as a fallback layer once other providers run out of quota).
- Point your tools (Claude Code / Cursor / Cline, etc.) at 9router's local entry point
http://localhost:20128/v1— from then on 9router decides when to route to QCode.
Direct QCode vs via 9router¶
| Direct QCode | Via 9router | |
|---|---|---|
| Config complexity | Low (one BASE_URL) | Medium (need to set up provider / tier / aliases) |
| Multi-provider fallback | None | Yes (QCode can be primary or fallback) |
| Team sharing | Yes (cloud service) | No (9router is local only; config isn't shared across members) |
| Usage stats | Accurate via QCode dashboard probe.qcode.cc | 9router only reflects its own routing choices; quotas still follow the QCode dashboard |
| Stability | Direct is most stable | One extra local proxy layer |
Notes¶
- Local only: 9router runs locally, and its config is not shared between team members.
- Image routing needs your own testing: 9router exposes
/v1/images/generations, but "calling QCode'sgpt-image-2via 9router" is untested and may need extra configuration; if you need reliability, route images via direct image-2. - Quotas follow the QCode dashboard: 9router's stats are not the same as your actual QCode account quota (per-Key daily limits, etc. follow the QCode dashboard / probe.qcode.cc).
- Protocol-to-path mapping:
/openai/v1uses the OpenAI protocol,/apiuses the Anthropic protocol, and/qcode-img/v1is for images — see Endpoints and API formats.
One API Key works across three protocols (Anthropic / OpenAI / Gemini), whether you connect directly or through a router like 9router. Learn about QCode.cc pricing.