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

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.