Codex will run any model you point it at, not just OpenAI's. Swapping takes about 5 minutes and you keep the tool you already know.

Why would you want to run another model?

You've used up your subscription allowance and don't want to stop working. Or you want to try DeepSeek, Qwen or GLM without learning a new setup to do it.

Current limitation: 1 provider at a time. Codex sends requests to a single provider, so you run either the OpenAI models or your new one. They don't sit side by side in the picker. That's how Codex is currently built, not something you've configured wrong. Switching back takes seconds, and Step 5 covers it.

What You'll Need

  • Codex installed and opened at least once, so the config file exists. Works with the desktop app, the terminal version, or the VS Code extension.

  • A DeepSeek API key with a few dollars of credit on it

  • Optional: an OpenRouter account if you want more than one model

  • 5 minutes

Step 1: Back Up Your Config

Codex keeps its settings at ~/.codex/config.toml. Copy it before you change anything:

cp ~/.codex/config.toml ~/.codex/config.toml.backup

Ten seconds now, and you can always get back to exactly where you started.

Step 2: Run DeepSeek's Setup Script

DeepSeek publish a script that writes the config for you. Open a terminal and run it:

curl -fsSL https://api-docs.deepseek.com/scripts/codex-setup.sh | sh

It'll ask for your API key, then update your config.

Check the script before you pipe it to your shell. Open the URL in a browser and read it first. Good practice with any install script, not a comment on DeepSeek specifically.

Customisation: if you'd rather not run a script, DeepSeek document the manual config in their Codex guide. About eight lines, and you can see exactly what changes.

Step 3: Restart and Check

Quit Codex fully and reopen it. The config is read at startup, so a running instance won't see the change.

Ask it:

Which model are you and who made you?

You should get DeepSeek. In the desktop app the picker will say "Custom" rather than naming the model. That's normal.

Step 4: If Something Looks Wrong

  • Your chats have gone. The script switches Codex from your ChatGPT account to an API key, and your history is tied to the account. It's hidden, not deleted. Delete the forced_login_method and preferred_auth_method lines from your config, restart, and it comes back.

  • The model didn't change. You probably didn't fully quit. Cmd+Q on Mac, or check the tray on Windows.

  • Every request fails. Almost always the API key. DeepSeek keys work but error on a zero balance.

Step 5: How to Switch Back

Easiest first.

Run the script again and pick option 3. It restores the config it backed up before making changes.

Or restore your own backup:

cp ~/.codex/config.toml.backup ~/.codex/config.toml

Or edit by hand. Open ~/.codex/config.toml and delete these lines, if present:

model = "deepseek-v4-flash"
model_provider = "deepseek"
model_catalog_json = "~/.codex/models.json"
preferred_auth_method = "apikey"
forced_login_method = "api"

Leave the [model_providers.deepseek] block. It does nothing on its own and saves setting it up again next time.

Restart Codex and you're back to normal.

Step 6: Add OpenRouter for More Models

Optional. DeepSeek gets you one provider. OpenRouter reaches hundreds of models through a single key and one bill, including Qwen and GLM.

Add this to ~/.codex/config.toml:

[model_providers.openrouter]
name = "OpenRouter"
base_url = "https://openrouter.ai/api/v1"
env_key = "OPENROUTER_API_KEY"

env_key takes the name of an environment variable, not your key. Pasting the key itself won't work, and it leaves it sitting in a file you might screenshot.

Set the key separately, and add the line to your ~/.zshrc so it survives a restart:

export OPENROUTER_API_KEY="your-key-here"

Then point Codex at whichever model you want:

model = "qwen/qwen3.8-max"
model_provider = "openrouter"

Change that one line to move between models. GLM 5.2 is z-ai/glm-5.2, DeepSeek is deepseek/deepseek-v4-flash. Check the current identifier on OpenRouter's models page first, because a wrong name fails silently.

When to Use a Cheaper Model

Your subscription is the cheapest way to do work by hand. It's a flat fee however much you use it, where API pricing is a meter running.

So this isn't about replacing your plan. It's for:

  • When you've hit your limit and still have work to finish

  • Jobs you run hundreds of times, where per-request cost adds up

  • Testing whether a cheaper model is good enough before you rely on it

For long, complex work across many files, stay on the premium models. For routine work, boilerplate, tests and documentation, DeepSeek and GLM hold up well.

One other thing worth checking: if the work touches sensitive client data, look at where the provider is based and what their retention policy says. Cheaper isn't the only consideration.

Real-World Applications

Agencies and Consultancies

Run bulk client work through a cheap model and keep your subscription for the hard problems.

Construction and Property

Document processing, spec comparison and tender drafting are high-volume and repetitive. Exactly the work that gets shelved when per-job cost doesn't stack up.

Small Teams

Run the same job on two models and compare. Cheaper to find out than to guess.

Tips for Better Results

  • Change one thing at a time. Get DeepSeek working before adding OpenRouter.

  • Keep the backup until you've used the new setup for a week.

  • Test on work you've already done. Give the model a task you know the answer to. Fastest way to judge quality.

  • Watch the first bill. Cheaper per request doesn't mean cheaper overall if you run more requests.

Next Steps

Pick the task you run most often in Codex. Run it on your current model, then on DeepSeek, and compare.

Start here:

Which model are you and who made you?

If that comes back as DeepSeek, you're set up correctly.

Keep Reading