Skip to content

Instantly share code, notes, and snippets.

@antenore
Last active November 27, 2025 10:41
Show Gist options
  • Select an option

  • Save antenore/c529e055e45559579b08b4961b517f8c to your computer and use it in GitHub Desktop.

Select an option

Save antenore/c529e055e45559579b08b4961b517f8c to your computer and use it in GitHub Desktop.
Configure OpenAI Codex CLI to use DeepSeek models

Configure OpenAI Codex CLI for DeepSeek

Two files needed to make DeepSeek work properly with Codex CLI:

1. ~/.codex/config.toml

model = "deepseek-reasoner"
model_provider = "deepseek-reasoner"
approval_policy = "on-failure"
sandbox_mode = "workspace-write"
project_doc_max_bytes = 32768

[model_providers.deepseek-reasoner]
name = "DeepSeek Reasoner"
base_url = "https://api.deepseek.com/v1"
env_key = "DEEPSEEK_API_KEY"
wire_api = "chat"
request_max_retries = 3
stream_max_retries = 5
stream_idle_timeout_ms = 180000

[model_providers.deepseek-chat]
name = "DeepSeek Chat"
base_url = "https://api.deepseek.com/v1"
env_key = "DEEPSEEK_API_KEY"
wire_api = "chat"
request_max_retries = 4
stream_max_retries = 8
stream_idle_timeout_ms = 120000

[profiles.deepseek-reasoner]
model = "deepseek-reasoner"
model_provider = "deepseek-reasoner"
approval_policy = "on-failure"
sandbox_mode = "workspace-write"
model_supports_reasoning_summaries = false

[profiles.deepseek-chat]
model = "deepseek-chat"
model_provider = "deepseek-chat"
approval_policy = "on-failure"
sandbox_mode = "workspace-write"
model_supports_reasoning_summaries = false

[sandbox_workspace_write]
exclude_tmpdir_env_var = false
exclude_slash_tmp = false
network_access = true

[shell_environment_policy]
inherit = "all"
ignore_default_excludes = false

[history]
persistence = "save-all"

2. ~/.codex/AGENTS.md

# Agent Instructions for Codex CLI

## DeepSeek Models Critical Instructions

### IF YOU ARE A DEEPSEEK MODEL:

**CRITICAL**: DeepSeek models MUST use the shell function for ALL command execution.

#### Shell Command Execution
- **ALWAYS** use the `shell` function to execute commands
- **NEVER** call commands directly
- Syntax: `shell(cmd=["bash", "-lc", "command"], workdir="path")`

Examples:
- List files: `shell(cmd=["bash", "-lc", "ls -la"], workdir=".")`
- Read file: `shell(cmd=["bash", "-lc", "cat filename"], workdir=".")`
- Search: `shell(cmd=["bash", "-lc", "rg 'pattern'"], workdir=".")`

#### File Operations
- Use provided file operation tools when available (read_file, write_file)
- Otherwise use shell commands through the shell function

### Working Directory
- Always set the `workdir` parameter when using shell function
- Use absolute paths or specify workdir instead of `cd`

### For All Models
- Respect sandbox mode settings
- Follow approval policy
- Handle errors gracefully

Setup

  1. Set API key:
export DEEPSEEK_API_KEY="your-key"
  1. Place config.toml in ~/.codex/config.toml
  2. Place AGENTS.md in ~/.codex/AGENTS.md
@andrewbell73
Copy link

Looks like many of us are seeing the DeepSeek API down — I’ve experienced the same. Maybe we can follow a systematic troubleshooting guide whenever the API goes down:

  1. First check the official status page to confirm whether the downtime is server‑side or just on our end.
  2. status.
  3. Verify your API key — ensure it’s active, correctly typed, and hasn’t expired.
  4. Check your network: unstable internet, VPN, firewall, or DNS issues can also cause failures.
  5. Review request payload: invalid JSON, wrong parameters or too large requests may cause errors.

If everything above looks correct but it’s still down, wait a while — sometimes the service may be overloaded or under maintenance (others have reported similar outages).

Optionally, implement fallback logic or retry mechanism in your code so your application can handle temporary downtime gracefully or follow step by steps instructions as given on deepseek api down related blog.

If others have additional tips — logging, rate‑limit checks or alternate endpoints — sharing them here might help the community avoid hours of frustration 🙂

@antenore
Copy link
Author

Looks like many of us are seeing the DeepSeek API down — I’ve experienced the same. Maybe we can follow a systematic troubleshooting guide whenever the API goes down:

  1. First check the official status page to confirm whether the downtime is server‑side or just on our end.
  2. status.
  3. Verify your API key — ensure it’s active, correctly typed, and hasn’t expired.
  4. Check your network: unstable internet, VPN, firewall, or DNS issues can also cause failures.
  5. Review request payload: invalid JSON, wrong parameters or too large requests may cause errors.

If everything above looks correct but it’s still down, wait a while — sometimes the service may be overloaded or under maintenance (others have reported similar outages).

Optionally, implement fallback logic or retry mechanism in your code so your application can handle temporary downtime gracefully or follow step by steps instructions as given on deepseek api down related blog.

If others have additional tips — logging, rate‑limit checks or alternate endpoints — sharing them here might help the community avoid hours of frustration 🙂

Nice, thanks for pointing this out...
Didn't check if this is possible, can you propose a patch to the gist?

Otherwise I'll check later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment