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.
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.
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)
| Model | Vendor | Context | Input / output (CNY per million tokens) |
|---|---|---|---|
| deepseek-v4-pro | DeepSeek | 1M | ¥5.85 / ¥17.55 |
| deepseek-v4.1-flash | DeepSeek | 1M | ¥1.95 / ¥5.85 |
| glm-5.2 | GLM | 1M | ¥6.80 / ¥23.80 |
| glm-5.3 | GLM | 1M | ¥6.80 / ¥23.80 |
| gpt-5.6-sol | OpenAI | 1.05M | ¥2.75 / ¥16.50 |
| gpt-6-astra | OpenAI | 1.05M | ¥5.50 / ¥27.50 |
| gpt-6-sol | OpenAI | 1.05M | ¥1.10 / ¥5.50 |
| gpt-6.1-sol | OpenAI | 1.05M | ¥1.10 / ¥5.50 |
| gpt-6.2-astra | OpenAI | 1.05M | ¥4.40 / ¥22.00 |
| gpt-6.2-sol | OpenAI | 1.05M | ¥1.10 / ¥5.50 |
| grok-4.6 | xAI | 500K | ¥1.00 / ¥3.00 |
| grok-4.7 | xAI | 500K | ¥1.00 / ¥3.00 |
| kimi-k3 | Kimi | 1M | ¥17.00 / ¥85.00 |
| kimi-k3.1-pro | Kimi | 1M | ¥11.05 / ¥57.80 |
| qwen3.7-max-2026-06-08 | Qwen | 1M | ¥10.20 / ¥30.60 |
| qwen3.7-plus-2026-05-26 | Qwen | 1M | ¥1.70 / ¥6.80 |
| qwen3.8-flash | Qwen | 1M | ¥0.68 / ¥2.295 |
| qwen3.8-max-0902 | Qwen | 200K | ¥10.20 / ¥30.60 |
A model missing from the table has not declared this protocol, or is not currently a public, priced model.
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:
model_providers in the user-level ~/.codex/config.toml. Codex ignores it in a project's .codex/config.toml.openai, ollama or lmstudio.base_url must end in /v1. Codex appends /responses; without /v1 it requests a path the gateway does not have.env_key is the name of an environment variable, not the key itself. Make sure the variable has a value in the terminal where you start codex.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.
base_url. On 2026-11-10 we checked Codex CLI 0.164.0 against a local simulated server (not a real upstream): with base_url ending in /v1, it requested /v1/responses, matching our Responses endpoint. We have not run a full conversation against a real upstream. If the connection fails, use the verification command to confirm the gateway works and compare against the official documentation.env_key has a value and the key was created on VisionCoder and is still active.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.