Endpoints & API Paths
QCode.cc's two API protocols (Anthropic / OpenAI), four access domains, and how to fill in BASE_URL
Endpoints & API Paths¶
This page consolidates how QCode.cc exposes two API protocols, four access domains, and how to set BASE_URL correctly. A single API Key works across both protocols — the protocol is chosen by the request path, and our backend routes automatically.
1. Two API Protocols¶
QCode.cc is compatible with both the Anthropic Messages and OpenAI protocols:
| Protocol | Typical Clients | Path |
|---|---|---|
| Anthropic Messages | Claude Code / Claude Agent SDK / Cline / Aider | /api/v1/messages or equivalently /claude/v1/messages |
| OpenAI Chat Completions | Official OpenAI SDK / LangChain / generic clients | /openai/v1/chat/completions |
| OpenAI Responses | Codex CLI (required for Codex) | /openai/v1/responses |
Request bodies follow the corresponding official schema (Anthropic POST /v1/messages, OpenAI POST /v1/chat/completions, OpenAI POST /v1/responses).
Note:
/api,/claude, and/openai/v1are path prefixes, not standalone endpoints. SDKs automatically append/v1/messages,/chat/completions, or/responses. Directly runningcurl https://api.qcode.cc/apiwill return 404 — that's expected.
2. Four Access Domains¶
All four domains serve identical business capabilities; they differ only in network routing:
| Domain | Target Users | Scheme | Notes |
|---|---|---|---|
api.qcode.cc |
Global (Route 53 latency-based) | HTTPS | Primary for outside China, picks nearest node |
us.qcode.cc |
North America | HTTPS | Los Angeles, launched 2026-04-22 |
eu.qcode.cc |
Europe | HTTPS | Frankfurt |
asia.qcode.cc |
Asia | HTTPS | Hong Kong |
103.236.53.153 |
Mainland China | HTTP | Shenzhen bare IP, lowest latency |
A single API Key works on all four domains — feel free to switch. Users in mainland China should use 103.236.53.153 (HTTP, not HTTPS) for the best latency.
3. BASE_URL Cheatsheet¶
Fill in the following based on your tool:
| Tool | Env Var / Config Key | Value | SDK Will Send To |
|---|---|---|---|
| Claude Code | ANTHROPIC_BASE_URL |
https://api.qcode.cc/api |
/api/v1/messages |
| Claude Agent SDK | base_url= constructor arg |
https://api.qcode.cc/api |
/api/v1/messages |
| Cline / Aider | Anthropic mode base URL | https://api.qcode.cc/api |
/api/v1/messages |
| OpenAI Python/JS SDK | base_url= constructor arg |
https://api.qcode.cc/openai/v1 |
/openai/v1/chat/completions |
| Codex CLI | TOML base_url = |
https://api.qcode.cc/openai |
/openai/v1/responses |
Mainland China users can swap the prefix https://api.qcode.cc for http://103.236.53.153 (note: HTTP).
4. Self-Test with curl¶
Before wiring up a full SDK, you can verify the path and network connectivity with a plain POST:
# Anthropic protocol path test
curl -X POST https://api.qcode.cc/api/v1/messages
# → Returns 401 — the path is correct; only Authorization is missing (expected)
# OpenAI Chat Completions test
curl -X POST https://api.qcode.cc/openai/v1/chat/completions
# → Returns 401
# OpenAI Responses (used by Codex)
curl -X POST https://api.qcode.cc/openai/v1/responses
# → Returns 401
Interpretation: 401 Unauthorized means the path mapping is correct and the network is reachable — only the auth header is missing. This is good news. If you get 404, the path prefix is wrong and you should consult Section 3.
End-to-end test with a real API Key:
curl -X POST https://api.qcode.cc/api/v1/messages \
-H "x-api-key: YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-5","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'
Swapping the domain to us.qcode.cc / eu.qcode.cc / asia.qcode.cc with the same path should produce the same result — this confirms the alternate domain is usable for you.
5. FAQ¶
Q: Why does curl https://api.qcode.cc/api return 404?
A: /api is a path prefix, not an endpoint. The full path is /api/v1/messages.
Q: Any difference between /api/v1/messages and /claude/v1/messages?
A: No. Both prefixes route to the Anthropic Messages protocol — use whichever your SDK defaults to. Our docs default to /api because that's what most Claude-ecosystem SDKs expect.
Q: Can one API Key call both Claude and Codex?
A: Yes. Keys are protocol-agnostic; the protocol is chosen by the request path. /api/v1/messages means Anthropic, /openai/v1/responses means OpenAI Responses.
Q: Which domain should I pick?
A: Mainland China → 103.236.53.153 (HTTP, Shenzhen direct). Everywhere else → api.qcode.cc (global routing). If your primary domain stalls, switch to us / eu / asia freely.
Q: Should I include a trailing slash in BASE_URL?
A: No. Most SDKs auto-append paths like /v1/messages; a trailing slash would produce //v1/messages and cause 404.