跪拜 Guibai
← All articles
Open Source

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

By iMountTai ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The official method of adding a second provider to Codex CLI overwrites the main config and forces an API-key-only login, which logs out the ChatGPT session. This profile-based workaround keeps both auth methods alive, so developers can evaluate DeepSeek's coding model without sacrificing their existing workflow.

Summary

Codex CLI can now switch between three isolated model profiles — default GPT, DeepSeek-V4-Flash, and an existing GPT-5.5 setup — by passing a profile flag. The key fix is keeping the main config.toml untouched and giving DeepSeek its own profile file that sets requires_openai_auth to false, so the ChatGPT login session in auth.json stays valid. A custom models.json entry registers DeepSeek-V4-Flash with its reasoning tiers, 1M-token context window, and tool capabilities, requiring Codex CLI 0.144.0 or later. Sessions are started with codex -p deepseek and resumed with the --last flag, and the API key lives only in the local deepseek.config.toml file.

Takeaways
Three model profiles — default GPT, DeepSeek-V4-Flash, and GPT-5.5 — coexist by using separate config files and the -p flag.
DeepSeek gets its own deepseek.config.toml with requires_openai_auth = false, preventing it from touching the ChatGPT auth.json session.
A models.json entry defines DeepSeek-V4-Flash's reasoning levels, 1,048,576-token context window, and tool support for Codex CLI 0.144.0+.
Sessions start with codex -p deepseek and resume with codex resume --last -p deepseek; the API key stays in the local profile file only.
Running codex login status still reports ChatGPT login, confirming the profiles are isolated.
Conclusions

Codex CLI's profile system was designed for environment switching, but the documentation omits the auth.json conflict that occurs when a second provider forces API-key login — this workaround fills that gap.

The models.json catalog is not just metadata; it gates which reasoning tiers and tools the client exposes, so a missing or misconfigured entry silently degrades the model's capabilities.

Setting requires_openai_auth = false while omitting forced_login_method and preferred_auth_method is the precise combination that prevents the logout prompt, suggesting the client checks those fields before invalidating the existing session.

Concepts & terms
Codex CLI profiles
Codex CLI's -p flag loads a named profile from a separate .toml file, allowing different model providers, API keys, and settings to coexist without modifying the default config.toml.
models.json catalog
A client-side model registry that tells Codex CLI what a model is called, its context window size, supported reasoning effort levels, and which tools it can use. Without a correct entry, the client may not expose the model's full capabilities.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗