DeepSeek-V4(Flash / Pro)接入 Codex(Windows 版)
2026/8/30 5:53:06 网站建设 项目流程

1. 能实现什么

  • 直接运行codex:继续使用默认的gpt-5.6-sol
  • 运行codex -p deepseek:进入 DeepSeek 会话,默认模型为deepseek-v4-flash。进入 DeepSeek 会话后执行/model:可在 Flash / Pro 之间切换,无需重启会话。
  • 运行codex -p deepseek -m deepseek-v4-pro:直接以deepseek-v4-pro启动。
  • 各 profile 配置互相隔离;切换 profile 时结束当前对话再启动对应 profile,不需要退出登录。

DeepSeek 官方 Responses API 的deepseek-v4-flashdeepseek-v4-pro均为正式版模型,两个模型共用同一个deepseekprofile。

2. 配置文件

配置目录:C:\Users\<用户名>\.codex

config.toml # 原有默认 GPT 配置,不修改 deepseek.config.toml # DeepSeek profile(Flash / Pro 共用) models.json # DeepSeek 模型目录(含 flash 与 pro 两个条目) auth.json # ChatGPT 登录态,不修改

3. DeepSeek 配置

新建C:\Users\<用户名>\.codex\deepseek.config.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 只保存在本机私有配置中,不要提交到仓库或写入共享文档。官方 Responses API 指南(https://api-docs.deepseek.com/zh-cn/guides/responses_api)中model参数同时支持deepseek-v4-flashdeepseek-v4-pro;profile 默认模型设为 Flash,Pro 通过-m/model选择。

models.json是 Codex 客户端的模型目录,通过model_catalog_json加载,用来识别模型名称、推理档位、上下文长度和工具能力。其根节点models数组需要包含 flash 与 pro 两个条目,字段结构一致:以 flash 条目为模板(下方 JSON),复制一份后只需修改 4 处即可得到 pro 条目。

字段flashpro
slugdeepseek-v4-flashdeepseek-v4-pro
display_nameDeepSeek-V4-FlashDeepSeek-V4-Pro
descriptionLatest frontier agentic coding model.Most capable frontier agentic coding model.
priority12
{"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":[]}

两个条目的visibility均为"list",因此/model会同时列出两个模型;条目要求 Codex CLI0.144.0或更高版本。

4. 启动、切换与恢复

默认 GPT:

codex

DeepSeek 新对话(默认 Flash):

codex-p deepseek

指定 Pro 启动:

codex-p deepseek-m deepseek-v4-pro

会话内切换:启动后输入/model,选择 DeepSeek-V4-Pro 或 DeepSeek-V4-Flash,后续消息即使用所选模型;该切换只影响当前会话,重启后回到 profile 默认的 Flash。

恢复最近一次会话:

codex resume--last-p deepseek

恢复指定会话:

codex resume <SESSION_ID>-p deepseek

恢复为 Pro 时在 resume 命令后加-m deepseek-v4-pro。本方案中-p deepseek用于选择 provider,-m可选、缺省为 Flash。

5. 登录态共存(重点)

官方 DeepSeek Codex 配置直接改主config.toml,并强制使用 API Key 登录时,会和已有 ChatGPT 登录态共用同一个auth.json,导致 ChatGPT 会话被要求退出或出现:

API key login is required, but ChatGPT is currently being used. Logging out.

当前方案通过以下方式保证共存:

  1. config.toml保留原来的 GPT 默认配置;
  2. DeepSeek 单独放在deepseek.config.toml,只通过-p deepseek加载;
  3. 设置requires_openai_auth = false,DeepSeek 使用自己的 API Key;
  4. DeepSeek profile 不设置forced_login_method = "api"preferred_auth_method = "apikey"

因此可以保持auth.json中的 ChatGPT 登录态,默认 GPT、DeepSeek 和 DAPTokens profile 可分别启动。切换 DeepSeek 时不要执行codex logout或重新登录。

6. 验证

codex login status codex-p deepseek

第一条命令仍应显示Logged in using ChatGPT;第二条命令进入 DeepSeek 对话。进入后执行/model,应能看到 DeepSeek-V4-Flash 与 DeepSeek-V4-Pro 两个选项并可切换;也可以先执行codex -p deepseek -m deepseek-v4-pro确认 Pro 模型可正常启动。

官方参考:Responses API 指南 https://api-docs.deepseek.com/zh-cn/guides/responses_api,模型版本与价格 https://api-docs.deepseek.com/zh-cn/quick_start/pricing/。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询