Skip to content

Run Codex CLI on Windows Using WSL

Install and run OpenAI Codex CLI on Windows with WSL. Setup, config.toml location, connecting a cheap model, env vars, and the WSL-specific gotchas to avoid.

MGMCSA Guru Team August 4, 2026 3 min read
Installing and running OpenAI Codex CLI inside WSL on Windows

OpenAI’s Codex CLI is fast and pleasant, and on Windows it behaves best inside WSL. It reads environment variables and a config.toml, and it assumes a Unix-like shell — exactly what WSL provides. This guide installs and runs Codex in WSL, including pointing it at a cheaper model, with the WSL details that matter.

If WSL isn’t installed, start with the WSL install guide. For the provider config in depth, see Codex CLI custom provider setup.

Step 1: Install Codex CLI in WSL

Recent Codex CLI ships as a Rust binary, though install methods vary (some via npm). Follow the Codex repository instructions inside WSL so the binary and its config live in the Linux environment. If it’s via npm, install Node first with nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
# then install Codex per the repo (npm or release binary)
codex --version

Step 2: Sign in or add a cheap provider

With an OpenAI account, sign in per the docs. To run on a cheaper model, add a provider in ~/.codex/config.toml:

model = "deepseek-chat"
model_provider = "deepseek"

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

Export the key in your shell profile so it persists:

echo 'export DEEPSEEK_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrc
codex

Swap the block for Qwen, GLM, or Kimi.

Step 3: Work in the Linux file system

For big repos, copy the project into your Linux home so Codex’s file operations stay fast:

cp -r /mnt/c/Users/YourName/myproject ~/myproject
cd ~/myproject
codex

See access your Windows files from WSL for the file-bridge details.

Codex in WSL essentials

Install per repo Rust binary or npm, inside WSL
~/.codex/config.toml Provider config in Linux home
wire_api = "chat" Required for third-party providers
key in ~/.bashrc Persist across shells
project in ~ Faster file operations

WSL gotchas

  • codex: command not found — reopen the shell after install so PATH updates.
  • Format/streaming errors — set wire_api = "chat" for non-OpenAI providers.
  • Key not found — export it in ~/.bashrc and source it; inline only lasts the session.
  • Slow on big repos — move the project into your Linux home.

Codex CLI on WSL checklist

  • WSL installed; Codex installed inside WSL
  • config.toml in ~/.codex (Linux home)
  • Cheap provider block with wire_api = "chat" (optional)
  • API key exported in ~/.bashrc
  • Active project in Linux home; tested

Wrapping up

On Windows, run Codex CLI in WSL for the cleanest experience: install it inside the Linux environment, keep config.toml in ~/.codex, and optionally add a cheap provider with wire_api = "chat" plus a key in ~/.bashrc. Keep active projects in your Linux home for speed.

For the provider details, see Codex CLI custom provider setup and the per-model guides like DeepSeek with Codex CLI.

Frequently asked questions

Should I run Codex CLI in WSL on Windows?

WSL is the smoother option. Codex reads environment variables and a config file and assumes a Unix-like shell, so WSL avoids the PATH and env-var quirks that native Windows can introduce. Both work, but WSL is less fiddly.

Where is the Codex config in WSL?

At ~/.codex/config.toml inside your Linux home directory. Keep it there rather than under /mnt/c so Codex reads it with the right permissions and the secrets stay in the Linux environment.

How do I use a cheap model with Codex in WSL?

Add a [model_providers.] block in config.toml with the provider's base URL, an env_key, and wire_api = "chat", then export the key in your shell profile. See the per-model Codex guides for exact values.

Do I need Node or Rust in WSL?

Recent Codex CLI ships as a fast Rust binary, but installation methods vary; some use npm. Follow the repo's current install instructions inside WSL so the binary and its config live in the Linux environment.

Why keep the project in the Linux file system?

Agent file operations are faster in your Linux home than across /mnt/c. For big repos, copy the project into ~ for the session to avoid the cross-boundary slowdown.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.