Codex CLI Custom Base URL: Configure a Third-Party Gateway in config.toml

How to point Codex CLI at your own API base URL. Covers why only the Responses protocol works, which models qualify, how to verify and what is not yet tested.

Home / Setup guides / Codex CLI Custom Base URL: Configure a Third-Party Gateway in config.toml

By VisionCoder team · Updated 2026-11-15 · Checked 2026-11-10

Disclosure: we build VisionCoder, one of the options below, so our description of it is the least neutral part. Statements about other products cite only their official docs, with the checked date (2026-11-10). Prices and models follow the live data below.

One rule to understand first

If you search for "Codex CLI custom base URL", you probably want Codex to talk to your own gateway. Codex does this through a model_providers entry in ~/.codex/config.toml, which has a wire_api field. Its configuration documentation says responses is the only supported value and also the default when omitted (checked 2026-11-10; sources at the end).

So Codex speaks the Responses protocol. The VisionCoder gateway does not convert protocols: a model can only be called over the protocols it has declared. For Codex, only models that declare Responses will work. Anything else returns a 400 with error number 400159, and the response lists the paths that model does support. That is not a configuration mistake; pick another model.

Which models work

The table below is generated from the public model catalog each time the page is served, and lists public models that declare the Responses protocol.

Live data (as of 2026-11-29)

ModelVendorContextInput / output (CNY per million tokens)
deepseek-v4-proDeepSeek1M¥5.85 / ¥17.55
deepseek-v4.1-flashDeepSeek1M¥1.95 / ¥5.85
glm-5.2GLM1M¥6.80 / ¥23.80
glm-5.3GLM1M¥6.80 / ¥23.80
gpt-5.6-solOpenAI1.05M¥2.75 / ¥16.50
gpt-6-astraOpenAI1.05M¥5.50 / ¥27.50
gpt-6-solOpenAI1.05M¥1.10 / ¥5.50
gpt-6.1-solOpenAI1.05M¥1.10 / ¥5.50
gpt-6.2-astraOpenAI1.05M¥4.40 / ¥22.00
gpt-6.2-solOpenAI1.05M¥1.10 / ¥5.50
grok-4.6xAI500K¥1.00 / ¥3.00
grok-4.7xAI500K¥1.00 / ¥3.00
kimi-k3Kimi1M¥17.00 / ¥85.00
kimi-k3.1-proKimi1M¥11.05 / ¥57.80
qwen3.7-max-2026-06-08Qwen1M¥10.20 / ¥30.60
qwen3.7-plus-2026-05-26Qwen1M¥1.70 / ¥6.80
qwen3.8-flashQwen1M¥0.68 / ¥2.295
qwen3.8-max-0902Qwen200K¥10.20 / ¥30.60

A model missing from the table has not declared this protocol, or is not currently a public, priced model.

Configuration points

Full steps and a working example are in the guide: Connect Codex CLI to VisionCoder. Here are the traps people usually fall into, without repeating the whole configuration:

Verify before you debug

Send one request with the verification command from the guide first. If it works and Codex does not, the problem is almost certainly the config file location or the base_url form, not the gateway.

Known limits

Common errors

Sources

Third-party names: GPT, Codex and similar names and trademarks belong to their respective owners. VisionCoder is not affiliated with them and uses the names only to describe callable models. Unofficial note: VisionCoder is not affiliated with the owners of Codex CLI, whose name and trademark belong to them.

Related guides

Sign in to get an API key

中文