Endpoints & API Paths

QCode.cc's three API protocols (Anthropic / OpenAI / Google Gemini), five access domains, and how to fill in BASE_URL


title: "Endpoints & API Paths" description: "QCode.cc's three API protocols (Anthropic / OpenAI / Google Gemini), four access domains, and how to fill in BASE_URL"


Endpoints & API Paths

This page consolidates how QCode.cc exposes three API protocols, four access domains, and how to set BASE_URL correctly. A single API Key works across all three protocols — the protocol is chosen by the request path, and our backend routes automatically.

1. Three API Protocols

QCode.cc is compatible with the Anthropic Messages, OpenAI, and Google Gemini 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 / DeepSeek-TUI / generic clients /openai/v1/chat/completions
OpenAI Responses Codex CLI (required for Codex) /openai/v1/responses
Google Gemini API Gemini CLI / OpenCode (google provider) / Google @google/genai SDK /gemini/v1beta/models/{model}:generateContent

Request bodies follow the corresponding official schema (Anthropic POST /v1/messages, OpenAI POST /v1/chat/completions, OpenAI POST /v1/responses, Google POST /v1beta/models/{model}:generateContent).

Note: /api, /claude, and /openai/v1 are path prefixes, not standalone endpoints. SDKs automatically append /v1/messages, /chat/completions, or /responses. Directly running curl https://api.qcode.cc/api will 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 (Backup) HTTPS Los Angeles, launched 2026-04-22
eu.qcode.cc Europe (Backup) HTTPS Frankfurt
asia.qcode.cc Asia (Backup) HTTPS Hong Kong

A single API Key works on all four domains — feel free to switch.

🇨🇳 Note for CN users: We recommend asia.qcode.cc (Hong Kong, lowest latency); switch to api.qcode.cc (global Route 53) if unstable. All domains report to probe.qcode.cc — enter your API Key on that page to inspect request details, context length, usage, and more.

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
DeepSeek-TUI (openai provider) TOML base_url = or OPENAI_BASE_URL https://api.qcode.cc/openai/v1 /openai/v1/chat/completions
Codex CLI TOML base_url = https://api.qcode.cc/openai /openai/v1/responses
OpenCode (google provider) baseURL https://api.qcode.cc/gemini/v1beta /gemini/v1beta/models/{model}:generateContent
Gemini CLI / Google @google/genai SDK base URL https://api.qcode.cc/gemini /gemini/v1beta/models/{model}:generateContent

Why two forms for Gemini? OpenCode's google provider does not auto-append /v1beta/, so the baseURL must include it (/gemini/v1beta). Gemini CLI and Google's official @google/genai SDK do auto-append /v1beta/, so the base URL only goes up to /gemini — appending /v1beta yourself would yield /gemini/v1beta/v1beta/... and return 404.

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

# Google Gemini protocol path test
curl -X POST https://api.qcode.cc/gemini/v1beta/models/gemini-2.5-pro:generateContent
# → Returns 401 / 400 = path is reachable (Gemini uses x-goog-api-key header or ?key= query)

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 Claude, Codex, and Gemini all?

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, /gemini/v1beta/models/... means Google Gemini.

Q: Should Gemini's baseURL end with /v1beta or not?

A: It depends on the tool. OpenCode's google provider needs it (set baseURL to /gemini/v1beta) because it does not auto-append /v1beta/. Gemini CLI and Google's @google/genai SDK do not (set base URL to /gemini) — the SDK appends /v1beta/ itself, and adding it manually would produce /gemini/v1beta/v1beta/... and return 404.

Q: Which domain should I pick?

A: Mainland China → asia.qcode.cc (Hong Kong, lowest latency) or api.qcode.cc (global Route 53); North America → us.qcode.cc; Europe → eu.qcode.cc. Switch freely between backups if your primary domain stalls.

Q: Can I see my own request history?

A: Yes. Requests sent through any domain (api.qcode.cc / asia.qcode.cc / us.qcode.cc / eu.qcode.cc) are reported to probe.qcode.cc. Enter your API Key there to view the request list, models, tokens, and more.

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.

Related Documents

Claude Code Complete Tutorial
From installation to mastery — A comprehensive guide to Claude Code covering setup, core features, model selection, practical examples and best practices
Codex vs Claude Code: An In-Depth Comparison
A comprehensive 2026 comparison of the two leading AI coding tools -- execution style, model capabilities, security, cost analysis, and how QCode.cc lets you use both
Quick Start
Learn Claude Code essentials in 5 minutes
🚀
Get Started with QCode — Claude Code & Codex
One plan for both Claude Code and Codex, Asia-Pacific low latency
View Pricing Plans → Create Account
Team of 3+?
Enterprise: dedicated domain + sub-key management + ban protection, from ¥250/person/mo
Learn Enterprise →