跪拜 Guibai
← Back to the summary

Run DeepSeek-V4-Flash Inside Codex CLI Without Breaking Your ChatGPT Login

1. What It Achieves

2. Configuration Files

Configuration directory: C:\Users\<username>\.codex

config.toml                 # Original default GPT config, do not modify
deepseek.config.toml        # DeepSeek profile
models.json                 # DeepSeek model metadata
auth.json                   # ChatGPT login state, do not modify
dap-gpt55.config.toml       # Original GPT-5.5 profile, do not modify

3. DeepSeek Configuration

Create C:\Users\<username>\.codex\deepseek.config.toml:

model = "deepseek-v4-flash"
model_provider = "deepseek"
model_reasoning_effort = "high"
model_catalog_json = "C:/Users/<username>/.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>"

Replace <DEEPSEEK_API_KEY> with your own DeepSeek API Key. The real key is saved only in the local private configuration; do not commit it to a repository or write it into shared documents.

models.json is not a DeepSeek API configuration, but rather the Codex client's model catalog, used to identify model names, reasoning tiers, context length, and tool capabilities. The official provider configuration does not expand on this item; currently, it is loaded locally by explicitly specifying model_catalog_json.

Add the following entry to the models array at the root of the existing models.json; do not overwrite other models in the array:

{
  "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": []
}

This entry requires Codex CLI version 0.144.0 or higher.

4. Starting and Resuming

Default GPT:

codex

New DeepSeek conversation:

codex -p deepseek

You can also explicitly specify the model:

codex -p deepseek -m deepseek-v4-flash

Resume a DeepSeek session:

codex resume --last -p deepseek -m deepseek-v4-flash

Or specify a session ID:

codex resume <SESSION_ID> -p deepseek -m deepseek-v4-flash

In this setup, -p deepseek selects the DeepSeek provider; the profile already configures the model, so -m can be omitted.

5. Login State Coexistence (Key Point)

The official DeepSeek Codex configuration directly modifies the main config.toml and forces API Key login, which shares the same auth.json with the existing ChatGPT login state, causing the ChatGPT session to be asked to log out or producing:

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

This setup guarantees coexistence through the following means:

  1. config.toml retains the original GPT default configuration;
  2. DeepSeek is placed separately in deepseek.config.toml, loaded only via -p deepseek;
  3. requires_openai_auth = false is set, so DeepSeek uses its own API Key;
  4. The DeepSeek profile does not set the following two items:
forced_login_method = "api"
preferred_auth_method = "apikey"

Therefore, the ChatGPT login state in auth.json is preserved, and the default GPT, DeepSeek, and DAPTokens profiles can each be started separately. When switching to DeepSeek, do not execute codex logout or re-login.

6. Verification

codex login status
codex -p deepseek

The first command should still show Logged in using ChatGPT; the second command enters a DeepSeek conversation.

Comments

Top 1 from juejin.cn, machine-translated. The original thread is authoritative.

瑾木

On the desktop client, can this also be done?