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

Updated 2026-10-15

Need an API key? Sign up →Endpoints & base URLs →

On This Page

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 model 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: 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, promotional 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

  1. Start 9router per its docs and open the local console (default http://localhost:20128).
  2. Under Providers, add a custom / OpenAI-compatible (Compatible Node) provider:

  3. 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.cc (the nearby Asia access point).
  4. API Key: your QCode API Key (starts with cr_).
  5. Models / aliases: register claude-opus-5, claude-sonnet-5, gpt-6-sol, gpt-5.6-terra, etc. as needed (4.x such as claude-sonnet-4-6 remains on sale).
  6. 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).
  7. 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
Path Direct 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's gpt-image-2 via 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/v1 uses the OpenAI protocol, /api uses the Anthropic protocol, and /qcode-img/v1 is for images — see Endpoints and API formats.

Install and the local endpoint (per the official 9router README)

As of 2026-10-15, the quick start in the official 9router README is: install with npm install -g 9router, start it with 9router, and open the dashboard at http://localhost:20128 by default. In the tool you want to connect, set the Endpoint to http://localhost:20128/v1 and copy the API Key from the 9router dashboard. The README also states that custom OpenAI / Anthropic compatible endpoints are supported, and that is how QCode is added.

Key settings explained

Item in 9router What to enter for QCode Notes
Type Custom / OpenAI compatible (Compatible Node) Claude models need an Anthropic-protocol node; whether the UI offers one is up to 9router
Base URL https://api.qcode.cc/openai/v1 (GPT, Chinese models) or https://api.qcode.cc/api (Claude) No trailing slash; use asia.qcode.cc in mainland China
API Key Your QCode key starting with cr_ The same key as for a direct connection
Model / alias For example claude-sonnet-5, gpt-6-sol An alias is only 9router's internal name; what reaches QCode must be the real model ID
tier / fallback chain Put QCode in the primary or fallback slot 9router decides the order; QCode only sees the requests that actually arrive

Common errors and how to troubleshoot

Symptom Likely cause Fix
The tool cannot reach localhost:20128 9router is not running, or the port is taken Check that the dashboard opens in a browser, then retest in the tool
Invalid API key Wrong or space-padded QCode key, or 9router's own key entered in the QCode provider They are two different keys: the tool gets the key from the 9router dashboard, the QCode provider gets the cr_ key
model_not_available_on_endpoint A Claude model was routed to the OpenAI endpoint Create a separate Anthropic-protocol node (/api) for Claude; see Endpoints and API formats
404 /v1 added or missing in the Base URL, or a trailing slash Compare with the table above
Usage differs from the QCode dashboard 9router's statistics only reflect its own routing Trust the QCode dashboard and probe.qcode.cc

Hit QCode directly with curl first (section 5 of Endpoints and API formats) to confirm the key and path, then debug the 9router layer. It saves a lot of back and forth.

FAQ

Do I need 9router if I only use QCode?

No. If you only use QCode, point the tool's BASE_URL straight at api.qcode.cc (or asia.qcode.cc in mainland China). It is simpler: one fewer local proxy and one fewer place for things to go wrong.

Why does the cost shown in 9router differ from my QCode bill?

The figures in 9router are its own estimates based on its routing choices. QCode bills per token, with per-model rates listed at qcode.cc/models, and the QCode dashboard is what actually counts.

Can Claude Code use Claude models through 9router?

Only if 9router supports an Anthropic-protocol node and you have configured QCode's /api address as such a node. With only an OpenAI-compatible node, Claude models are rejected. The exact UI is described in the official 9router repository.

How do I confirm that requests passing through 9router really reach QCode?

Enter your cr_ key at probe.qcode.cc; if you can see the model and tokens of the request, it arrived. If not, check whether the QCode provider is in 9router's tier / fallback chain and whether it is placed early enough.


One API Key works across two protocols (Anthropic / OpenAI), whether you connect directly or through a router like 9router. Learn about QCode.cc pricing.

Get started with QCode

One API key for Claude Code, Codex and more — billed per token, per-model prices on qcode.cc/models

Enterprise →