AI

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

This tutorial covers only the Windows configuration process, how to verify it, and where to check first if there is a problem. Model name, client […]

article directories

This tutorial covers only the Windows configuration process, how to verify it, and where to check first if there is a problem.
The model name, client version, and official script content may be updated over time. Please use the information currently displayed on the DeepSeek official page for actual operation.

Reference:

  • DeepSeek Official Codex Access Guide
  • DeepSeek official configuration script

1. Preparation: Apply for DeepSeek API Key

First go to the DeepSeek console to create an API Key:

https://platform.deepseek.com/top_up

API Key Security Considerations

If the old Key once appeared in the following locations:

  • screenshot
  • chat records
  • Articles Tutorial
  • code repository
  • social platform

Please deactivate it immediately in DeepSeek console and do not continue to use it.

New API Key:

  • Enter only on your own computer
  • Don't send it to anyone
  • Don't take screenshots to show
  • Do not submit to the code warehouse

Also need to note:

The official DeepSeek configuration script does not only temporarily use Key in the current PowerShell window. It may write authentication information to the Codex user configuration directory.

Therefore, the following directories also need to be protected as sensitive directories:

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

Don't upload the entire .codex Folder, and don't share configuration files within it.

The API Key page in the tutorial screenshot suggests:

  • 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