Skip to content

Instantly share code, notes, and snippets.

@antenore
Last active October 27, 2025 11:36
Show Gist options
  • Save antenore/c529e055e45559579b08b4961b517f8c to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment