OpenAI 的 Codex,最近有多火,不用多说了吧。魔方把自己的Obsidian+Claude Code 系统也增加了Codex的选项,这样可以两个同时使用了。
写代码、debug、重构项目,一条指令搞定。
但问题是,它虽然开源,但是必须开通ChatGPT Plus 才能用,一个月20美金,API 调用按 token 计费,重度用下来一个月几百块打不住。
其实有一条免费路子已经跑通了:用 CC Switch 把 Codex 接到 DeepSeek 上,链接成本直接归零。(注意,这里说的不是token费用为0,只是不需要开通plus会员了而已)(如果真想要token也免费,也不是做不到,点关注,关注后续雄文)
为什么能免费?两个API之间的技术坑被填上了
Codex 本身是开源的,不强制绑定 OpenAI。你给它一个兼容的接口和 API Key,它就认。DeepSeek 的接口跟 OpenAI 兼容,价格却低得多。
但有个技术坑:Codex 用的是 OpenAI 的 Responses API 协议,DeepSeek 用的是 Chat Completions API,两个协议不完全一样。直接配置会报错。
CC Switch 从 v3.16.0 开始,内置了协议转换引擎,自动把 Responses API 翻译成 Chat Completions API,把这个问题解决了。
准备3样东西,5分钟就能搞定
装之前,先准备好三样东西:
CC Switch:去 GitHub 搜索 cc-switch,下载最新版(需要 v3.16.0 以上)。支持 Windows 和 macOS。怕版本不对的,可以在文末找到下载链接。
Codex:分两种,命令行版(Codex CLI,终端里跑)和桌面版(Codex App,有图形界面)。任选一个。
DeepSeek API Key:去 platform.deepseek.com 注册,在 API Keys 页面创建一个 key(sk- 开头)。新账号有免费额度,日常够用。
4步配置,最容易漏掉第3步
第一步:装好 Codex 并登录
Codex CLI 安装:
npm install -g @openai/codex
桌面版直接去 OpenAI 官网下载安装包。
装完后先跑一次codex命令,用 ChatGPT 账号登录一次(浏览器弹窗授权即可)。这一步是为了激活 Codex 的基础功能,后面再切到 DeepSeek。
第二步:在 CC Switch 中添加 DeepSeek
打开 CC Switch,顶部切到「Codex」标签页。
点右上角的「+」按钮,在预设下拉菜单里选「DeepSeek」。把你的 API Key 粘贴进去,点添加。
这是最容易漏掉的一步。
进入 CC Switch 的「设置」→「路由」,确保两个开关都打开。
路由总开关:开。Codex 路由启用:开。
如果不开,Codex 的请求不会走 CC Switch,直接去了 OpenAI 官方,等于白配。
第四步:启用并重启
回到 CC Switch 主界面,点 DeepSeek 供应商卡片上的「启用」按钮。
然后一定要重启 Codex。Codex 不支持热加载配置,不重启不会生效。
重启后再跑 Codex,虽然界面上显示的模型名字可能还是 GPT 系列(这是显示问题,CC Switch 通过文件注入方式接管了配置),但实际上已经在调用 DeepSeek 了。
找不到“008-终端跑DeepSeek.png”。
花几毛钱验证一下,别白配了
最直接的办法:用 Codex 随便写几段代码,然后去 DeepSeek 开放平台的费用中心看账单。有消费记录产生,就说明链路正常。
总结
这套方案的核心就一句话:CC Switch 做中转,Codex 免费跑在 DeepSeek 上。
三步记住就行:装 CC Switch、加 DeepSeek、开路由。最容易踩的坑是忘了开路由开关和忘了重启 Codex。
重申一下,想要免费token的,可以蹲守后续文章不管你信不信:真的有免费的全模态API了,也可以自己按照魔方之前的文章区倒腾。
CC-Switch-v3.16.1-Windows-的下载链接已经准备好了:https://pan.quark.cn/s/ceb95a9d2092
OpenAI's Codex, no need to explain how popular it is recently. I've added the Codex option to my Obsidian+Claude Code system, so I can use both simultaneously.
Write code, debug, or refactor projects with a single command.
The problem is, although it is open-source, you must subscribe to ChatGPT Plus to use it — $20 per month, with API calls billed by token. Heavy usage can cost hundreds per month.
There's actually a free route that works: connect Codex to DeepSeek via CC Switch, slashing the cost to zero. (Note: this doesn't mean tokens are free — just that you don't need a Plus subscription.) If you want truly free tokens, it's possible; follow my future articles.
Why is it free? The technical gap between the two APIs has been bridged.
Codex is open-source and not tied to OpenAI. If you provide a compatible interface and API key, it accepts it. DeepSeek's interface is compatible with OpenAI but much cheaper.
However, there's a technical hitch: Codex uses the OpenAI Responses API protocol, while DeepSeek uses the Chat Completions API — they're not identical. Direct configuration causes errors.
CC Switch (from v3.16.0) includes a built-in protocol translation engine that automatically converts Responses API calls to Chat Completions API, solving this issue.
Prepare three things, and you're set in 5 minutes:
Before installation, get these:
CC Switch: Search GitHub for cc-switch, download the latest version (must be v3.16.0 or later). Windows and macOS supported. If unsure, use the link at the end.
Codex: Choose either the command-line version (Codex CLI) or desktop app (Codex App). Both work.
DeepSeek API Key: Register at platform.deepseek.com, create a key (starts with sk-). New accounts get free credits, enough for daily use.
Four steps to configure — don't miss step 3!
1. Install and log in to Codex
For CLI: npm install -g @openai/codex
For desktop: download from OpenAI's website.
After installation, run codex and log in with your ChatGPT account (via browser popup). This activates basic Codex functionality — we'll switch to DeepSeek later.
2. Add DeepSeek in CC Switch
Open CC Switch, go to the "Codex" tab.
Click "+" at top-right, select "DeepSeek" from the preset dropdown, and enter your API key. Save.
Go to Settings → Routing in CC Switch. Ensure both switches are ON:
- Routing main switch
- Codex routing enabled
Without this, requests go directly to OpenAI, bypassing the free DeepSeek path.
4. Enable and restart
Back in the main CC Switch interface, click "Enable" on the DeepSeek provider card.
Finally, restart Codex (via Terminal or GUI) — it doesn't support hot-reloading.
Now, even if the model name still shows as GPT (due to UI limitations), the backend is actually calling DeepSeek.
To verify: write some code using Codex and check your DeepSeek billing dashboard for usage — if there's activity, you're good.
In summary: CC Switch relays your calls to DeepSeek, making Codex free from subscription fees. Just remember: install CC Switch, add DeepSeek, enable routing, and restart Codex.
Download CC-Switch-v3.16.1-Windows here: https://pan.quark.cn/s/ceb95a9d2092
总结
The core of this solution is one sentence: CC Switch acts as a proxy, allowing Codex to be run for free on DeepSeek.
Just remember three steps: install CC Switch, add DeepSeek, and enable routing. The most common pitfalls are forgetting to turn on the routing switch and forgetting to restart Codex.
To reiterate, if you want free tokens, you can wait for subsequent articles (like "Unbelievable: There Really Is a Free Full-Modal API") or tinker with it yourself based on previous Cube articles.
The download link for CC-Switch-v3.16.1-Windows is ready: https://pan.quark.cn/s/ceb95a9d2092

