AI

How to insert Codex into DeepSeek API: Windows configuration, version, and troubleshooting

本教程仅介绍 Windows 环境下的配置流程、验证方法,以及出现问题后应该优先检查的位置。 模型名称、客户端 […]

article directories

本教程仅介绍 Windows 环境下的配置流程、验证方法,以及出现问题后应该优先检查的位置。
模型名称、客户端版本、官方脚本内容可能随时间更新,实际操作时请以 DeepSeek 官方页面当前显示的信息为准。

参考:

  • DeepSeek 官方 Codex 接入指南
  • DeepSeek 官方配置脚本

一、准备工作:申请 DeepSeek API Key

首先前往 DeepSeek 控制台创建 API Key:

https://platform.deepseek.com/top_up

API Key 安全注意事项

如果旧 Key 曾经出现在以下位置:

  • screenshot
  • 聊天记录
  • 文章教程
  • 代码仓库
  • 社交平台

请立即在 DeepSeek 控制台撤销,不要继续使用。

新的 API Key:

  • 只在自己的电脑中输入
  • 不要发送给任何人
  • 不要截图展示
  • 不要提交到代码仓库

另外需要注意:

DeepSeek 官方配置脚本并不是只在 PowerShell 当前窗口临时使用 Key,它可能会把认证信息写入 Codex 用户配置目录。

因此以下目录也需要作为敏感目录保护:

C:\Users\你的用户名\.codex\

不要上传整个 .codex 文件夹,也不要分享其中的配置文件。

教程截图中的 API Key 页面建议:

  • Must be coded
  • Use relative paths to save picture resources to avoid failure after changing computers or publishing

Example:

![DeepSeek API key 页面,密钥已打码](./assets/deepseek-api-key-redacted.png)

2. Run the DeepSeek official configuration script

Open Windows PowerShell and execute:

irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex

The order would:

  1. Download PowerShell scripts from DeepSeek's official address
  2. Perform the configuration process immediately

Although the address comes from the official, it should be noted:

Direct execution of remote scripts remains inherently risky.

Don't copy similar commands from unfamiliar tutorials.

If you are not at ease, you can:

  1. Open the script content first
  2. Confirm source
  3. re-execution

configuration steps

After the script appears in the menu:

  1. Enter:
1
  1. Choose:
deepseek-v4-flash
  1. Follow the prompts to enter the newly created DeepSeek API Key
  2. Wait for the script to complete configuration

Reminders about deepseek-v4-pro

The appearance of certain model names in the script menu does not mean that the current client version and official access status are fully supported.

Don't choose a model directly just because you see the name of a model in the menu.

Correct way:

  • Subject to DeepSeek official current documents
  • Confirm model name
  • Confirm client version requirements
  • Confirm recommended access method

Don't:

  • Insert the Key into the command
  • Write the Key to the public script
  • Show the real Key in the article

3. Restart Codex and perform three-phase verification

After configuration is complete:

  1. Quit the Codex desktop completely
  2. Re-open Codex

Then don't start modifying the project directly.

It is recommended to verify in the following order.


Step 1: Basic model request testing

Enter:

只回复 OK

If returned:

OK

Description:

  • The API request was basically successful
  • Provider configuration may be normal

If:

  • 401
  • model does not exist
  • Provider error

Don't let Codex operate on the project yet.

Priority inspections:

  • API Key
  • model name
  • Provider configuration
  • client version

Step 2: Read only file test

Enter:

只读当前工作区中的一个文本文件,告诉我它主要写了什么,不要修改任何文件

Used to confirm:

  • Does Codex have access to the workspace
  • Whether the file reading function is normal

Step 3: Simple tool call test

Enter:

只列出当前工作区中的文件名,不要创建、删除或修改任何文件

Used to confirm:

  • Whether the tool call is normal
  • Whether the workspace permissions are normal

Why break it into three steps?

Because:

  • Basic request failed → Most likely due to key, model, and provider issues
  • File reading failed → Possible workspace permissions or client issues
  • Tool call failed → Possible problem with Codex tool chain

Separate testing can quickly identify the cause.


4. Original configuration backup location

Official scripts usually create backup directories:

C:\Users\Administrator\.codex\backup-deepseek\

If the Windows username is not Administrator:

View:

C:\Users\你的用户名\.codex\backup-deepseek\

This catalog may contain:

  • Provider configuration
  • API address
  • authentication information

Don't:

  • Upload to online disk
  • Send it to others for review
  • Put it in public warehouse

5. Terminal version of Codex: Confirm the version first

Don't mix the desktop version of Codex and the terminal version of Codex together.

If using the terminal version:

Implement first:

codex --version

For example, some environments detect:

0.117.0

However, DeepSeek's official configuration scripts may require a higher version, such as:

0.144.0+

Version requirements are subject to change, so current official instructions must prevail.

When you need to upgrade:

npm install -g @openai/codex

Reconfirm after upgrade:

codex --version

Note:

If you only use desktop:

Don't use the terminal version number to prove that the desktop has been successfully connected.

The final judgment criterion should be:

  • Whether the corresponding Provider appears on the desktop
  • Whether the model request was successful
  • Whether file reading and tool calling are normal

6. Troubleshooting common errors

1. 401 or authentication failed

Priority inspections:

Whether the leaked old Key was used

If Key has ever been made public:

Undo and recreate immediately.

Whether to copy the error

Check:

  • space before and after
  • newline characters
  • Whether the input is complete

Don't send the Key to others for inspection.

Correct way:

Re-create the Key and enter it only during local configuration.


2. Model does not exist or version is unsupported

Confirm first:

codex --version

Then confirm:

  • Are you currently using the desktop version or the terminal version
  • DeepSeek official current required model names
  • Official minimum client version required

If the version is too low:

  1. upgrade the client
  2. Rerun the configuration script
  3. and then verify it.

3. Don't use DeepSeek Key in the OpenAI login process

Do not use:

codex login --with-api-key

Reason:

DeepSeek API Key is not an OpenAI login credential.

DeepSeek should pass:

  • Custom Provider
  • API address configuration
  • corresponding communication protocol

Make access.


Three last points to remember

  1. The old Key was exposed and revoked as soon as possible.
  2. DeepSeek API Key is not an OpenAI login credential.
  3. The appearance of a model in the interface does not mean that model requests, file readings, and tool calls are completely normal.

The criterion for successful configuration is not "seeing the model name", but:

  • request was successful
  • File reading normal
  • Tool call normal