Integrate with Codex
发布时间:2026-09-01 | 浏览:2
Codex is an AI coding assistant from OpenAI. It talks to models via the Responses API , which the DeepSeek API natively supports.
All Codex clients — Codex CLI, the ChatGPT desktop app, and the Codex IDE extension for VS Code — share the same configuration file. Configure it once as described below, and DeepSeek models will be available in all of them.
1. Configure DeepSeek as the Model Provider
Option 1: One-Click Setup Script (Recommended)
We provide a setup script that completes the whole configuration automatically. Before running it, make sure Codex CLI or the ChatGPT desktop app is installed and has been launched at least once (so that the ~/.codex directory exists).
macOS / Linux users, run in the terminal:
Windows users, run in PowerShell:
After launching, choose the model you want to use from the menu: deepseek-v4-flash (option 1), deepseek-v4-pro (option 2), or deepseek-v4-flash-vision-exp (option 3, which additionally accepts image input ). Option 9 restores the default Codex configuration, removing the DeepSeek-related settings. On first run, the script asks for your API Key (starting with sk- ; get one from the DeepSeek Platform ).
The script performs the following steps:
Back up your existing configuration : ~/.codex/config.toml is backed up to ~/.codex/backup-deepseek/ , so you can restore it at any time.
Write the model catalog ~/.codex/models.json : this declares the metadata of DeepSeek models to Codex (context window size, supported reasoning effort levels, tool call formats, etc.), so that Codex can use DeepSeek models just like its built-in models.
Modify ~/.codex/config.toml : only the necessary fields are rewritten (see the field reference below), and a [model_providers.deepseek] section is added; your existing settings such as MCP servers and project trust levels are all preserved. If any existing fields conflict with the DeepSeek configuration, the script removes them and prints the reason for each removal.
Validate : the script validates the syntax of config.toml / models.json before writing; if validation fails, it aborts without modifying any file.
Run the script again at any time to switch models from the menu, or to restore the configuration to its pre-installation state (menu option 9).
Option 2: Edit the Configuration File Manually
First, create the model catalog file ~/.codex/models.json , which declares the metadata of DeepSeek models to Codex. Its content is as follows (identical to what the setup script writes, containing deepseek-v4-flash , deepseek-v4-pro , and deepseek-v4-flash-vision-exp ). The deepseek-v4-flash-vision-exp entry declares image in input_modalities , which is what tells Codex the model accepts images:
Then, edit the Codex configuration file ~/.codex/config.toml (create it if it does not exist), and add the following content. Set experimental_bearer_token to your API Key (get one from the DeepSeek Platform ):
config.toml Field Reference
2. Get Started
Once configured, Codex CLI, the ChatGPT desktop app, and the Codex IDE extension for VS Code all read the same configuration file — no per-client configuration is needed:
Codex CLI : enter your project directory and run the codex command. If the startup banner shows model: deepseek-v4-flash (or the model you selected), the configuration is in effect. cd /path/to/my-project codex
Codex CLI : enter your project directory and run the codex command. If the startup banner shows model: deepseek-v4-flash (or the model you selected), the configuration is in effect.
ChatGPT desktop app : on Mac, the model picker shows "Custom" when the configuration is in effect; on Windows, it may show either "Custom" or "DeepSeek-V4-Flash". When "Custom" is shown, the model actually in use is the DeepSeek model you selected.
ChatGPT desktop app : on Mac, the model picker shows "Custom" when the configuration is in effect; on Windows, it may show either "Custom" or "DeepSeek-V4-Flash". When "Custom" is shown, the model actually in use is the DeepSeek model you selected.
Codex IDE extension for VS Code : shares the same configuration as Codex CLI; simply install the extension and start using it.
Codex IDE extension for VS Code : shares the same configuration as Codex CLI; simply install the extension and start using it.
If your previous sessions seem to be missing after switching to DeepSeek, don't worry — nothing is deleted. Codex stores session history in separate groups by login method: sessions created with an official ChatGPT subscription and sessions created with a third-party API (such as DeepSeek) are kept apart, and only the group matching the current configuration is shown. Restoring the previous configuration (e.g. via menu option 9 of the setup script) brings the earlier sessions back, while the DeepSeek sessions become hidden in turn. Restart the ChatGPT client after switching for the change to take effect.
1. Configure DeepSeek as the Model Provider Option 1: One-Click Setup Script (Recommended) Option 2: Edit the Configuration File Manually config.toml Field Reference
Option 1: One-Click Setup Script (Recommended)
Option 2: Edit the Configuration File Manually
config.toml Field Reference