DeepSeek as the default model on ChatGPT Codex
DEV Community

DeepSeek as the default model on ChatGPT Codex

Setting DeepSeek as the Default Model on ChatGPT Codex

In this article, I will explain how you can set DeepSeek as the default model for your Codex coding agent. By doing this, you no longer need to pay a flat monthly subscription. You only need to top up your DeepSeek API balance and pay for exactly what you use.

1. Preparing Your API Key

Before editing any files, you need access to the DeepSeek API. Generate an API key from your DeepSeek developer dashboard. Once you have it, set it as an environment variable named DEEPSEEK_API_KEY on your machine. This ensures Codex can authenticate without hardcoding your credentials into the configuration file.

# ~/.zshrc or ~/.bashrc
export DEEPSEEK_API_KEY=your-deepseek-api-key

2. Updating the Main Configuration

Codex reads its settings from a local configuration file. Open ~/.codex/config.toml in your preferred editor. You need to point the model catalog to a custom JSON file and define the DeepSeek provider settings. Update your config.toml to include these lines:

# ~/.codex/config.toml
model = "deepseek-flash"
model_provider = "deepseek"
model_catalog_json = "~/.codex/models.json"

[model_providers.deepseek]
name = "DeepSeek"
base_url = "https://api.deepseek.com"
env_key = "DEEPSEEK_API_KEY"
wire_api = "responses"

This configuration tells Codex to use the DeepSeek API endpoint and look for the DEEPSEEK_API_KEY environment variable.

3. Defining the Model Catalog

Next, create or edit the ~/.codex/models.json file. This file tells Codex how to interact with the specific model you selected, including its context window and supported tool settings. Add the following JSON structure:

{
  "models": [
    {
      "slug": "deepseek-flash",
      "display_name": "DeepSeek-Flash",
      "description": "Latest frontier agentic coding model with image input.",
      "input_modalities": ["text", "image"],
      "context_window": 1048576,
      "max_context_window": 1048576,
      "default_reasoning_level": "high",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "high",
          "description": "Extra high reasoning depth for complex problems"
        },
        {
          "effort": "max",
          "description": "Maximum reasoning depth for the hardest problems"
        }
      ],
      "truncation_policy": {
        "mode": "tokens",
        "limit": 10000
      },
      "supports_parallel_tool_calls": true,
      "supports_search_tool": true,
      "supported_in_api": true,
      "support_verbosity": true,
      "experimental_supported_tools": [],
      "priority": 1,
      "visibility": "list",
      "shell_type": "shell_command",
      "model_messages": {
        "instructions_template": "You are Codex, an agent based on DeepSeek-Flash. You are a coding agent working with the user in their workspace. Inspect the repository before editing files, use available tools carefully, make minimal changes, run relevant tests, and clearly report what changed."
      },
      "base_instructions": "You are Codex, an agent based on DeepSeek-Flash. You are a coding agent working with the user in their workspace. Inspect the repository before editing files, use available tools carefully, make minimal changes, run relevant tests, and clearly report what changed."
    }
  ]
}

This setup fully maps the model, so Codex knows it supports parallel tool calls, large context windows, and specific reasoning levels.

4. Applying the Changes

After saving both files, close and restart your Codex application. Look at the bottom right corner of the interface. You should now see DeepSeek-Flash listed as the active default model. You are now ready to generate code and manage your workspace using DeepSeek, relying entirely on usage-based API billing. Don't forget to source ~/.zshrc to load up your API Key into the shell environment.

5. Cost Comparison

The main reason to switch from a monthly subscription to an API key is cost control. When you pay per token, you only pay for what you use. DeepSeek models are significantly cheaper than OpenAI equivalents.

Here is the current pricing for OpenAI models per one million tokens.

Model Input Cost (per 1M) Output Cost (per 1M)
GPT-6 Astra $10.00 $50.00
GPT-5 $1.25 $10.00
GPT-4o $5.00 $15.00

Here is the off-peak pricing for DeepSeek V4 models per one million tokens.

Model Input Cost (per 1M) Output Cost (per 1M)
DeepSeek-V4-Flash $0.22 $0.66
DeepSeek-V4-Pro $0.66 $1.98

To understand what this means in practice, consider a standard week of coding. A moderate user might consume 500,000 input tokens from codebase context and generate 100,000 output tokens. If you use GPT-5, the input costs $0.63, and the output costs $1.00. Your total for the week is $1.63. If you use DeepSeek-V4-Flash (off-peak), the input costs $0.11, and the output costs $0.07. Your total for the week is $0.18. By switching, your operating cost drops to a fraction of the price without losing coding capability. You can run large refactoring tasks without worrying about subscription limits or high API bills.

Where to go next

  • How I manage my VPS with Pi's SSH extension - See how a local coding agent handles server work over SSH without leaving your terminal.
  • AI engineering vs AI native engineer - Understand the shift from integrating API calls to designing systems where AI is the core compute layer.
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.