Codex CLI with a custom provider (config.toml)
I run qcode.cc, an independent API service (not official Anthropic, OpenAI or Google). The examples use QCode paths; swap the host for any compatible gateway.
The short version
Codex talks the OpenAI Responses protocol and appends /responses to base_url. A gateway that only implements Chat Completions will not work with wire_api = "responses".
# ~/.codex/config.toml
model_provider = "qcode"
model = "gpt-6.2-sol"
model_reasoning_effort = "high"
[model_providers.qcode]
name = "qcode"
base_url = "https://api.qcode.cc/openai"
wire_api = "responses"
requires_openai_auth = true
With requires_openai_auth = true the key is read from ~/.codex/auth.json:
{ "OPENAI_API_KEY": "cr_your_key" }
Prefer an environment variable? Replace requires_openai_auth = true with env_key = "QCODE_API_KEY" and export QCODE_API_KEY=cr_your_key. Pick one of the two: Codex ignores env_key when requires_openai_auth is true.
Details that trip people up
- On QCode,
/openai/responsesand/openai/v1/responsesare equivalent; the docs say this was tested on 2026-10-27. - Regional hosts with the same paths:
https://asia.qcode.cc(mainland China side) andhttps://us.qcode.cc(North America and Europe). - Do not put a trailing slash on
base_url. gpt-6.2-*models rejectmodel_reasoning_effort = "none"; keephighorxhigh.- Chinese models (GLM, Kimi, DeepSeek, Qwen) are not served on the Responses endpoint, so they will not work in Codex; use a Chat Completions client for them.
- Claude models are not available on the OpenAI paths; use Claude Code with
ANTHROPIC_BASE_URLwith the same key.
Check it
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://api.qcode.cc/openai/v1/responses -H "Authorization: Bearer $KEY"
# 400 = path and key accepted (no body), 401 = bad key, 404 = wrong prefix
Docs: Codex quick start · one-click install. Troubleshooting any gateway: endpoint checker.
Facts checked against docs.qcode.cc on 2026-12-05. I run qcode.cc. Pricing: qcode.cc/pricing (no free quota). Contact: hi@qcode.cc.