# How to Use DeepSeek Models in Codex

> Configure Codex to use DeepSeek models with DeepSeek's official setup script, verify the result, and restore your previous configuration.

- Author: Kai Wang (AI Kai)
- Published: 2026-08-23
- Updated: 2026-08-23
- Topic: Codex
- Tags: codex, deepseek, model-provider
- Canonical: https://hqman.me/blog/deepseek-codex-integration/

DeepSeek provides an official setup script for using its models with Codex. The script updates Codex's model provider settings, creates a model catalog, and keeps a backup that can be restored later.

![Codex connected to DeepSeek through a local proxy](https://hqman.me/media/blog/deepseek-codex-integration/codex-deepseek-proxy.webp)

This guide covers the macOS and Linux script as checked on August 23, 2026. The available models and configuration format may change, so inspect the current script before running it.

## Before You Start

You need:

- Codex CLI or the ChatGPT desktop app installed and opened at least once
- A DeepSeek API key from [DeepSeek Platform](https://platform.deepseek.com/)
- A macOS or Linux shell with Bash and curl

The setup script writes the API key into your local Codex configuration. Protect that file as you would any other credential, and never commit it to Git.

## Inspect the Official Script

Running a remote shell script changes local configuration, so download and inspect it first:

```sh
curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh \
  -o /tmp/codex-deepseek-setup-en.sh
less /tmp/codex-deepseek-setup-en.sh
```

The script comes from DeepSeek's official CDN. At the time of review, it creates `~/.codex/models.json`, updates `~/.codex/config.toml`, and stores its backup under `~/.codex/backup-deepseek`.

## Run the Setup

After reviewing the file, run it:

```sh
bash /tmp/codex-deepseek-setup-en.sh
```

Choose a model from the menu, then enter your DeepSeek API key when prompted. The script validates the generated JSON and, when a suitable Python version is available, checks the TOML before replacing the active files.

If `~/.codex/models.json` already exists and was not created by this script, the installer stops instead of overwriting it. Review and back up that file before deciding how to resolve the conflict.

## Verify the Configuration

For Codex CLI, start a new session and check the model shown in the startup banner.

For the ChatGPT desktop app, fully quit and reopen the app. The model picker should show `Custom` or the selected model name, depending on the app version.

If the client reports an unknown model or fallback metadata, rerun the official installer and review its validation output.

## Switch Models or Restore Codex

Run the same script again. Use its model menu to switch providers, or choose option 9 to restore the configuration saved by the installer.

The restore path removes the generated model catalog and restores the previous `config.toml` when a backup exists.

## What the Script Changes

The installer configures DeepSeek as a Codex model provider, points it at `https://api.deepseek.com/`, selects the Responses wire format, and creates model metadata for the options offered in its menu.

Because this integration changes local client configuration and stores a credential locally, review the generated files after installation and keep the Codex configuration directory out of version control.

Source: [DeepSeek's official Codex setup script](https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)
