1. 能实现什么
- 直接运行
codex:继续使用默认的gpt-5.6-sol。 - 运行
codex -p deepseek:使用 DeepSeek-V4-Flash。 - 运行
codex -p dap-gpt55:继续使用原有 GPT-5.5 / DAPTokens 配置。 - 三套配置互相隔离;切换时结束当前对话,再启动对应 profile,不需要退出登录。
2. 配置文件
配置目录:C:\Users\<用户名>\.codex
text
config.toml # 原有默认 GPT 配置,不修改
deepseek.config.toml # DeepSeek profile
models.json # DeepSeek 模型元数据
auth.json # ChatGPT 登录态,不修改
dap-gpt55.config.toml # 原有 GPT-5.5 profile,不修改
3. DeepSeek 配置
新建 C:\Users\<用户名>\.codex\deepseek.config.toml:
toml
model = "deepseek-v4-flash"
model_provider = "deepseek"
model_reasoning_effort = "high"
model_catalog_json = "C:/Users/<用户名>/.codex/models.json"
disable_response_storage = true
[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
requires_openai_auth = false
experimental_bearer_token = "<DEEPSEEK_API_KEY>"
将 <DEEPSEEK_API_KEY> 替换为自己的 DeepSeek API Key。真实 Key 只保存在本机私有配置中,不要提交到仓库或写入共享文档。
models.json 不是 DeepSeek API 配置,而是 Codex 客户端的模型目录,用来识别模型名称、推理档位、上下文长度和工具能力。官方 provider 配置没有展开这一项;当前本机通过 model_catalog_json 显式加载它。
在已有 models.json 的根节点 models 数组中加入下面这个条目,不要覆盖数组里的其它模型:
json
{
"slug": "deepseek-v4-flash",
"display_name": "DeepSeek-V4-Flash",
"description": "Latest frontier agentic coding model.",
"default_reasoning_level": "high",
"supported_reasoning_levels": [
{ "effort": "low", "description": "Fast responses with lighter reasoning" },
{ "effort": "high", "description": "Extra high reasoning depth for complex problems" },
{ "effort": "max", "description": "Maximum reasoning depth for the hardest problems" }
],
"shell_type": "shell_command",
"visibility": "list",
"minimal_client_version": "0.144.0",
"supported_in_api": true,
"priority": 1,
"support_verbosity": true,
"default_verbosity": "low",
"apply_patch_tool_type": "freeform",
"web_search_tool_type": "text",
"supports_search_tool": true,
"input_modalities": ["text"],
"supports_image_detail_original": false,
"truncation_policy": { "mode": "tokens", "limit": 10000 },
"supports_parallel_tool_calls": true,
"multi_agent_version": "v2",
"use_responses_lite": false,
"context_window": 1048576,
"max_context_window": 1048576,
"reasoning_summary_format": "experimental",
"default_reasoning_summary": "none",
"supports_reasoning_summaries": true,
"prefer_websockets": false,
"include_skills_usage_instructions": false,
"experimental_supported_tools": []
}
当前条目要求 Codex CLI 0.144.0 或更高版本。
4. 启动和恢复
默认 GPT:
powershell
codex
DeepSeek 新对话:
powershell
codex -p deepseek
也可以显式指定模型:
powershell
codex -p deepseek -m deepseek-v4-flash
恢复 DeepSeek 会话:
powershell
codex resume --last -p deepseek -m deepseek-v4-flash
或指定会话 ID:
powershell
codex resume <SESSION_ID> -p deepseek -m deepseek-v4-flash
本方案中 -p deepseek 用于选择 DeepSeek provider;profile 已经配置模型,因此 -m 可以省略。
5. 登录态共存(重点)
官方 DeepSeek Codex 配置直接改主 config.toml,并强制使用 API Key 登录时,会和已有 ChatGPT 登录态共用同一个 auth.json,导致 ChatGPT 会话被要求退出或出现:
text
API key login is required, but ChatGPT is currently being used. Logging out.
当前方案通过以下方式保证共存:
config.toml保留原来的 GPT 默认配置;- DeepSeek 单独放在
deepseek.config.toml,只通过-p deepseek加载; - 设置
requires_openai_auth = false,DeepSeek 使用自己的 API Key; - DeepSeek profile 不设置以下两项:
toml
forced_login_method = "api"
preferred_auth_method = "apikey"
因此可以保持 auth.json 中的 ChatGPT 登录态,默认 GPT、DeepSeek 和 DAPTokens profile 可分别启动。切换 DeepSeek 时不要执行 codex logout 或重新登录。
6. 验证
powershell
codex login status
codex -p deepseek
第一条命令仍应显示 Logged in using ChatGPT;第二条命令进入 DeepSeek 对话。