Codex with third-party models: DeepSeek, Kimi, GLM and Qwen
Short answer: add a model_providers.lazu table to ~/.codex/config.toml with base_url = "https://api.lazu.ai/v1", put your key in the LAZU_API_KEY environment variable, and Codex can use GPT-6.1 Sol through Lazu, as well as third-party models such as DeepSeek, Kimi, GLM and Qwen. The CLI, the IDE extension and the desktop app read the same file.
Which models work in Codex #
Codex speaks only OpenAI's Responses API (/v1/responses); Chat Completions support has been removed. A model works in Codex if Lazu serves it on the Responses endpoint:
| Maker | Models (examples) |
|---|---|
| OpenAI | gpt-6.1-sol, gpt-6-sol, gpt-6-astra, gpt-6-luna |
| DeepSeek | deepseek-v4-pro, deepseek-flash |
| Moonshot | kimi-k3 |
| Zhipu | glm-5.3, glm-5.3-flash |
| Qwen | qwen3.8-max, qwen3.8-flash |
| MiniMax | MiniMax-M2.7 |
gemini-3.7-flash |
The model catalog marks every model that supports Responses.
Claude models don't work in Codex yet. By default Codex sends tools that OpenAI hosts, such as web_search, and asks for encrypted reasoning back. Neither has a counterpart on Claude, so Lazu refuses the request and names the field. Use Claude Code for Claude. Gemini doesn't work in Codex yet either.
The quick way: one script #
In Console › API Keys, pick a key, choose Connect, choose Codex and copy the one-line script:
curl -fsSL https://api.lazu.ai/setup/codex | sh -s -- --model gpt-6.1-sol
The script asks for the key in the terminal, so it never appears in your command line or history. It writes config.toml, adds LAZU_API_KEY to your shell startup file and sends one test request. On Windows, use the PowerShell version from the same dialog.
Manual setup #
Open ~/.codex/config.toml and put these lines at the top of the file. Top-level keys must come before the first table header (a line in square brackets), or TOML reads them as part of that table.
model_provider = "lazu"
model = "gpt-6.1-sol"
web_search = "disabled"
[model_providers.lazu]
name = "Lazu"
base_url = "https://api.lazu.ai/v1"
env_key = "LAZU_API_KEY"
wire_api = "responses"
Then set the key. With zsh, add this line to the end of ~/.zshrc and open a new terminal:
export LAZU_API_KEY="sk-lazu-..."
| Key | What it does |
|---|---|
model_provider |
Makes Codex use the lazu provider defined below. openai, ollama and lmstudio are reserved names. |
model |
The default model, one of the IDs above |
web_search |
Recommended off. By default Codex calls OpenAI's hosted web search tool, which third-party models may not support. |
base_url |
Where requests go; it ends in /v1 |
env_key |
The environment variable Codex reads the key from. Don't put the key in the TOML file. |
wire_api |
Must be responses |
Provider settings only take effect in ~/.codex/config.toml; a project's .codex/config.toml cannot set them.
Switching to DeepSeek, Kimi or GLM #
The simplest switch is the model line:
model = "deepseek-v4-pro"
For a model ID it does not recognise, Codex falls back to generic settings: it assumes a 272K context and does not enable the file-editing tool it uses with GPT models. To list these models in /model with suitable settings, let the script build a model catalog:
curl -fsSL https://api.lazu.ai/setup/codex | sh -s -- --model gpt-6.1-sol --also deepseek-v4-pro --also kimi-k3 --also glm-5.3
The script reads your Codex version's catalog format with codex debug models --bundled, writes ~/.codex/lazu-models.json, and points model_catalog_json at it. Run it again after you upgrade Codex.
Codex's prompts, tools and reasoning settings are tuned for GPT models. Third-party models connect, but multi-step tool calls, file edits and reasoning effort behave differently from model to model. Try a small task in a scratch directory first and check the edits before using one on a real project.
Two setups, one switch #
To move between "GPT for the hard work" and "DeepSeek to save money", use a profile. Since Codex 0.134.0 the old profiles tables are gone; a profile is now its own file:
# ~/.codex/deepseek.config.toml
model = "deepseek-v4-pro"
codex --profile deepseek
Codex reads ~/.codex/config.toml first and then applies deepseek.config.toml on top.
Prices #
GPT-6.1 Sol, read live from the catalog:
gpt-6.1-solOpenAI · 1.05M · Stable $2.00 / $10.00Model page →USD per million tokens
A request whose input (cached tokens included) passes the threshold is billed entirely at the long-context prices.
A dash means no price is recorded, not free usage. The request receipt is the final billing record.
DeepSeek V4 Pro:
deepseek-v4-proDeepSeek · 1M · Stable $0.825 / $2.48Model page →USD per million tokens
A dash means no price is recorded, not free usage. The request receipt is the final billing record.
The console's usage log shows the cost of every request. To see what a whole Codex task cost, reconcile its session.
GPT-6 Sol also has a discount lane. It is a reverse-engineered channel: a third-party supplier connects through the official client, not the official API. It is much cheaper and only accepts requests from the Codex client. To use it, switch that model to Discount on the key in the console; config.toml stays the same.
Check that it works #
codex exec "Introduce yourself in one sentence"
An answer means you are connected. The console's usage log shows the model, lane and cost of that request.
Troubleshooting #
401: Codex did not get LAZU_API_KEY. Check echo $LAZU_API_KEY in a new terminal. For the desktop app: an app launched from the Dock or Launchpad may not see variables set in your terminal. If a restart doesn't fix it, start the app from a terminal or provide the key through Codex's auth command option.
Model not found: the ID is wrong, the model has no Responses endpoint, or the key is limited to other models. Check the model catalog.
Can I use Claude? Not yet, for the reason above. Use Claude Code; see Claude Code with a custom API.