LogoHypereal AI
ModelsCoding LLMLimited
Products
  • AI Image GeneratorCreate images with AI
  • AI Video GeneratorCreate videos with AI
  • AI Avatar GeneratorTalking avatars & lip sync
  • AI Audio GeneratorVoices, music & speech
  • AI ToolsUpscale, swap, edit & more
  • AppsOne-click creative apps
Infrastructure
  • GPU CloudOn-demand GPU compute
  • Rent GPUBare-metal GPU rental
  • Train ModelsFine-tune & LoRA training
  • ComfyUI as APIDeploy ComfyUI workflows
  • Deploy Any ModelServerless model hosting
Developers
  • DocsAPI reference & guides
  • Hypereal SDKRun any model from code
  • Enterprise APIProduction-grade gateway
  • Stable Diffusion APIOpen-source checkpoints
  • CookbookRecipes & code examples
Company
  • EnterpriseTalk to our team
  • BlogProduct & eng updates
  • ChangelogLatest releases
  • InspirationGallery & showcases
  • Be a CreatorJoin the creator program
  • AffiliatePartner program
  • AboutOur mission & team
AgentPricingDocsEnterpriseAffiliate
Start Building
Hypereal AI
  • Models
  • Coding LLM
  • Products
  • GPU Cloud
  • Rent GPU
  • Train Models
  • ComfyUI as API
  • Deploy Any Model
  • Stable Diffusion API
  • Hypereal SDK
  • Agent
  • Pricing
  • Docs
  • Enterprise
  • Affiliate
Back to Articles
AIDeveloper ToolsWindowsTutorial

How to Use Codex on Windows with WSL (2026)

Set up OpenAI Codex CLI on Windows using WSL2

Hypereal AI TeamHypereal AI Team
7 min read
February 6, 2026
100+ AI Models, One API

Start Building with Hypereal AI

Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.

Get Free API KeyView Docs

No credit card required • 100k+ developers • Enterprise ready

How to Use Codex on Windows with WSL (2026)

OpenAI Codex CLI is a terminal-based AI coding assistant that can read your codebase, write code, run commands, and manage files -- all from the command line. The catch: it is designed for macOS and Linux. If you are on Windows, you need to run it through WSL (Windows Subsystem for Linux).

This guide walks you through the complete setup, from installing WSL to running Codex on your Windows machine.

What Is OpenAI Codex CLI?

Codex CLI is OpenAI's open-source command-line tool for AI-assisted software development. Think of it as a terminal-native coding agent that can:

  • Read and understand your entire project structure
  • Write, edit, and refactor code across multiple files
  • Run shell commands and interpret the output
  • Debug errors by reading logs and stack traces
  • Work with any programming language

It runs locally but uses OpenAI's API (or compatible endpoints) for the language model backend.

Prerequisites

Requirement Details
Windows 10 (build 19041+) or Windows 11 WSL2 requires a recent Windows version
Administrator access Needed for WSL installation
OpenAI API key Get one at platform.openai.com
8+ GB RAM WSL2 runs a real Linux kernel alongside Windows
Stable internet Required for API calls to OpenAI

Step 1: Install WSL2

If you do not already have WSL2 installed, open PowerShell as Administrator and run:

wsl --install

This installs WSL2 with Ubuntu as the default distribution. Restart your computer when prompted.

After reboot, the Ubuntu terminal will open automatically. Set up your Linux username and password.

Verify WSL2 is running

# In PowerShell
wsl --list --verbose

You should see something like:

  NAME      STATE           VERSION
* Ubuntu    Running         2

If the VERSION column shows 1, upgrade to WSL2:

wsl --set-version Ubuntu 2

Step 2: Set Up the Linux Environment

Open your WSL terminal (search for "Ubuntu" in the Start menu) and update packages:

sudo apt update && sudo apt upgrade -y

Install Node.js

Codex CLI requires Node.js 18+. Install it via nvm (Node Version Manager):

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

# Reload shell config
source ~/.bashrc

# Install Node.js LTS
nvm install --lts

# Verify
node --version  # Should show v22.x or later
npm --version

Install Git (if not present)

sudo apt install -y git

Step 3: Install Codex CLI

Install Codex globally via npm:

npm install -g @openai/codex

Verify the installation:

codex --version

Step 4: Configure Your API Key

Codex needs an OpenAI API key to function. Set it as an environment variable:

# Add to your shell config for persistence
echo 'export OPENAI_API_KEY="sk-your-api-key-here"' >> ~/.bashrc
source ~/.bashrc

Alternatively, create a .env file in your project directory:

echo 'OPENAI_API_KEY=sk-your-api-key-here' > .env

Using a Different LLM Provider

Codex supports any OpenAI-compatible API. To use a different provider, set the base URL:

# Example: Using a local Ollama instance
export OPENAI_API_KEY="ollama"
export OPENAI_BASE_URL="http://localhost:11434/v1"

# Example: Using xAI Grok
export OPENAI_API_KEY="your-xai-key"
export OPENAI_BASE_URL="https://api.x.ai/v1"

Step 5: Access Your Windows Files

WSL can access your Windows file system through /mnt/c/. Your Windows projects are available at:

# Navigate to a Windows project directory
cd /mnt/c/Users/YourUsername/Projects/my-app

# List files
ls -la

For better performance, clone repositories directly into the WSL file system:

# WSL-native directory (much faster I/O)
cd ~
mkdir projects
cd projects
git clone https://github.com/your-repo/my-app.git

Important: File operations on /mnt/c/ are significantly slower than on the native WSL filesystem (~/). For best Codex performance, work in your WSL home directory.

Step 6: Run Codex

Navigate to your project directory and start Codex:

cd ~/projects/my-app

# Start Codex in interactive mode
codex

# Or give it a direct task
codex "Add error handling to all the API route handlers in this project"

Codex Autonomy Modes

Codex has three autonomy levels that control how much it can do without asking:

Mode Flag What It Can Do
Suggest --suggest Read files, suggest changes (default)
Auto-edit --auto-edit Read files, apply code changes
Full auto --full-auto Read files, edit code, run commands
# Let Codex make code changes automatically
codex --auto-edit "Refactor this Express app to use TypeScript"

# Let Codex run commands too (use with caution)
codex --full-auto "Set up ESLint and Prettier for this project, install dependencies, and fix all linting errors"

Practical Examples

Fix a bug from an error message:

codex "I'm getting 'TypeError: Cannot read property of undefined' on line 42 of src/utils/parser.ts. Fix it."

Add tests for existing code:

codex "Write unit tests for all functions in src/services/auth.ts using Jest"

Refactor a component:

codex "Convert the UserProfile class component in src/components/UserProfile.jsx to a functional component with hooks"

Troubleshooting Common Issues

"codex: command not found"

Make sure the npm global bin directory is in your PATH:

# Check where npm installs global packages
npm config get prefix

# Add to PATH if needed
echo 'export PATH="$PATH:$(npm config get prefix)/bin"' >> ~/.bashrc
source ~/.bashrc

Slow file access

If Codex is slow when working with files on /mnt/c/, move your project to the WSL filesystem:

cp -r /mnt/c/Users/YourUsername/Projects/my-app ~/projects/my-app
cd ~/projects/my-app

WSL memory usage

WSL2 can consume a lot of memory. Create a .wslconfig file in your Windows home directory to limit it:

# C:\Users\YourUsername\.wslconfig
[wsl2]
memory=8GB
processors=4
swap=4GB

Restart WSL after changing the config:

# In PowerShell
wsl --shutdown

Network issues (API calls failing)

If Codex cannot reach the OpenAI API, check your DNS settings in WSL:

# Check if DNS resolution works
nslookup api.openai.com

# If it fails, fix DNS
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]\ngenerateResolvConf = false" > /etc/wsl.conf'

GUI applications and clipboard

To copy Codex output to your Windows clipboard:

# Pipe output to Windows clipboard
codex "explain this function" | clip.exe

# Or install xclip for bidirectional clipboard
sudo apt install -y xclip

VS Code Integration

For the best experience, use VS Code with the WSL extension:

  1. Install the "WSL" extension in VS Code
  2. Open your WSL project with code . from the WSL terminal
  3. VS Code's integrated terminal will use WSL automatically
  4. Run Codex directly in the VS Code terminal
# From your WSL project directory
code .

# Then in VS Code's terminal (which is now WSL)
codex "Add a README with setup instructions for this project"

Codex vs. Other AI Coding Tools

Feature Codex CLI Claude Code Cursor GitHub Copilot
Interface Terminal Terminal IDE IDE
File editing Yes Yes Yes Suggestions only
Command execution Yes Yes Limited No
WSL support Via WSL Via WSL Native Native
Open source Yes No No No
Model flexibility Any OpenAI-compatible Claude only Multiple GPT-based
Offline mode No (needs API) No No No
Price API costs only Claude subscription $20+/month $10+/month

Wrapping Up

Running Codex on Windows through WSL gives you the same experience as macOS and Linux users. The setup takes about 15 minutes and the WSL2 integration is mature enough that you will barely notice the difference. For the best performance, keep your project files on the WSL filesystem rather than accessing Windows drives.

If your projects involve AI-generated media alongside code, check out Hypereal AI for a unified API that handles image generation, video, talking avatars, and more.

Try Hypereal AI free -- 35 credits, no credit card required.

Related Articles

How to Add Custom API Keys to Cursor: Complete Guide (2026)

9 min read

Claude Code API: Use Claude Code with Hypereal

4 min read

How to Use Claude Code Completely Free (2026)

8 min read

On this page

  • How to Use Codex on Windows with WSL (2026)
  • What Is OpenAI Codex CLI?
  • Prerequisites
  • Step 1: Install WSL2
  • Verify WSL2 is running
  • Step 2: Set Up the Linux Environment
  • Install Node.js
  • Install Git (if not present)
  • Step 3: Install Codex CLI
  • Step 4: Configure Your API Key
  • Using a Different LLM Provider
  • Step 5: Access Your Windows Files
  • Step 6: Run Codex
  • Codex Autonomy Modes
  • Practical Examples
  • Troubleshooting Common Issues
  • "codex: command not found"
  • Slow file access
  • WSL memory usage
  • Network issues (API calls failing)
  • GUI applications and clipboard
  • VS Code Integration
  • Codex vs. Other AI Coding Tools
  • Wrapping Up
Desktop agent

Download Hypereal Agent

Run a local AI media workspace for image generation, video prompts, model selection, credit tracking, and saved artifacts.

MacWindows
v0.1.2Requires a hypereal.cloud API keyRelease manifest
Hypereal Agent desktop app screenshot

Start Building Today

Start building now
LogoHypereal AI
All systems normal
Infrastructure
  • Rent GPU
  • Train Models
  • ComfyUI as API
  • Deploy Any Model
  • GPU Cloud
  • LoRA Training API
  • Explore Catalog
  • Infrastructure Docs
  • GPU Logs
  • Pricing
LLM API
  • Hypereal SDK
  • Enterprise API
  • Coding Credits
  • All LLM Models
  • Claude Opus 4.7
  • Claude Sonnet 4.6
  • GPT-5.5
  • Claude Haiku 4.5
  • GPT-5.5 Pro
  • GPT-5.3 Codex
  • Gemini 3.1 Pro Preview
  • Gemini 3.5 Thinking
  • Gemini 3.5 Fast
  • DeepSeek V4 Pro
  • Kimi K2.6
  • GLM-5.1
  • Claude Code Alternative
  • Claude API in China
  • OpenAI API in China
AI API
  • AI API Overview
  • Seedance 2.0 API
  • Kling 3.0 API
  • Veo 3.1 API
  • FLUX API
  • GPT Image 2 API
  • vs WaveSpeed
  • vs fal.ai
  • vs Replicate
  • vs KIE.ai
  • vs OpenRouter
  • vs Together AI
  • vs SiliconFlow
  • Midjourney Alternative
  • Higgsfield Alternative
  • OpenRouter Alternative
Video Models
  • Google Veo 3.1 API
  • Kling 3.0 API
  • Kling O3 Pro API
  • Seedance 2.0 API
  • HappyHorse 1.0 API
  • WAN 2.7 API
  • WAN Video API
  • Grok Video API
  • Hunyuan Video API
  • PixVerse V6 API
  • Pika Video API
  • Luma Dream Machine API
  • MiniMax Video API
  • Vidu Video API
  • Gemini Omni Video API
Image Models
  • NanoBanana 2 API
  • FLUX 2 API
  • GPT Image 1 API
  • Grok Image API
  • SeeDream V5 API
  • Imagen 4 API
  • Ideogram API
  • Recraft API
  • DALL-E 3 API
  • Stable Diffusion API
  • Gemini Image API
Tools
  • Face Swap API
  • Video Face Swap API
  • Virtual Try-On API
  • Image Upscaler API
  • Video Upscaler API
  • AI Talking Avatar API
  • Lip Sync API
  • OmniHuman Avatar API
  • Tripo3D H3.1 API
  • ElevenLabs TTS API
  • Fish Audio TTS API
  • Whisper STT API
  • Lyria Music API
Generators
  • Hypereal Agent
  • Apps
  • AI Image Generator
  • AI Video Generator
  • AI Avatar Generator
  • AI Audio Generator
  • AI 3D Generator
  • AI Tools
  • Image Upscaler
  • Video Upscaler
Collections
  • Best Video Models
  • Best Image Models
  • Seedance 2.0
  • WAN 2.7
  • Qwen Image 2
  • Grok AI
  • Seedance 1.5
  • Motion Control
  • Content Detection
  • Object Detection
Company
  • About
  • Docs
  • Hypereal SDK
  • Cookbook
  • Blog
  • Articles
  • Changelog
  • Contact
  • FAQ
  • Tips & Tutorials
  • Roadmap
  • Enterprise
  • Affiliate Program
  • Platform
  • Inspiration
  • Be a Creator
  • Developer Program
Legal
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Cookie Policy
  • Pricing
  • All Models
  • Sitemap
  • Status
© Copyright 2026. All Rights Reserved.
TwitterGitHubLinkedInYouTubeEmail