Login
Back to Blog
Codex CLI Installation Guide 2026 for WSL, Devcontainers, and Proxies

Codex CLI Installation Guide 2026 for WSL, Devcontainers, and Proxies

C
Crazyrouter Team
March 21, 2026
1 viewsEnglishTutorial
Share:

Codex CLI Installation Guide 2026 for WSL, Devcontainers, and Proxies#

Most Codex CLI installation guides stop at npm install and call it a day. That is fine for a clean laptop. It is useless for the environments many developers actually use: WSL, remote SSH boxes, containers, locked-down corporate networks, or ephemeral development environments.

This tutorial focuses on those real setups.

What is Codex CLI?#

Codex CLI is a terminal coding assistant that lets you run AI-powered code analysis, edits, and task execution from the shell. It is useful for repository navigation, code generation, refactors, and quick scripting.

Developers like it because it fits existing workflows:

  • terminal-first work
  • scriptable commands
  • remote development compatibility
  • reproducible setup through dotfiles or containers

Codex CLI vs alternatives#

ToolBest forWeak spot
Codex CLIOpenAI-aligned coding flowsMay need extra work in locked-down environments
Claude CodeStrong reasoning in repo tasksDifferent pricing and workflow assumptions
Gemini CLILong-context experimentsLess standard in some teams
Crazyrouter + SDKBuild your own coding workflowsMore DIY

How to install Codex CLI#

macOS or Linux#

bash
npm install -g @openai/codex
codex --help

WSL setup#

bash
sudo apt update
sudo apt install -y nodejs npm
npm install -g @openai/codex
export OPENAI_API_KEY='your-key'
codex --help

Devcontainer setup#

Add Node and the CLI to your container image:

Dockerfile
FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm
RUN npm install -g @openai/codex
ENV OPENAI_BASE_URL=https://crazyrouter.com/v1

Proxy-aware environment#

bash
export HTTPS_PROXY=http://proxy.example.com:8080
export HTTP_PROXY=http://proxy.example.com:8080
export OPENAI_BASE_URL=https://crazyrouter.com/v1
export OPENAI_API_KEY=YOUR_CRAZYROUTER_KEY
codex

Using a compatible endpoint like Crazyrouter helps when you want one key for GPT, Claude, Gemini, and other coding-capable models from the same client surface.

Usage examples#

Python environment bootstrap helper#

python
import os

required = ['OPENAI_API_KEY', 'OPENAI_BASE_URL']
missing = [key for key in required if key not in os.environ]
if missing:
    raise SystemExit(f'Missing env vars: {missing}')

print('Environment ready for Codex-compatible tools')

Node.js test request against the same endpoint#

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: process.env.OPENAI_BASE_URL
});

const res = await client.chat.completions.create({
  model: 'gpt-5.2-codex',
  messages: [{ role: 'user', content: 'Write a bash script that checks disk usage.' }]
});

console.log(res.choices[0].message.content);

cURL smoke test#

bash
curl https://crazyrouter.com/v1/chat/completions   -H 'Authorization: Bearer YOUR_CRAZYROUTER_KEY'   -H 'Content-Type: application/json'   -d '{
    "model": "gpt-5.2-codex",
    "messages": [
      {"role": "user", "content": "Return a one-line shell command to find large files."}
    ]
  }'

Pricing breakdown#

The installation itself is cheap. The real cost comes from the model behind the CLI.

ModelOfficial input / 1MOfficial output / 1MRole
GPT-5.2$1.75$14.00Premium coding
GPT-5 mini$0.25$2.00Fast assistant
Claude Sonnet 4.6$3.00$15.00Strong repo reasoning
Gemini 2.5 Flash$0.30$2.50Cheap helper model
Access pathCost profile
Direct Codex-style stackBest if you only use OpenAI models
CrazyrouterBetter if you want routing or fallback

FAQ#

Can I install Codex CLI in WSL?#

Yes. WSL works well as long as Node is installed and your environment variables are set correctly.

Does Codex CLI work in devcontainers?#

Yes. Baking the package and environment variables into the image is the cleanest approach.

What if my company uses an HTTP proxy?#

Set HTTP_PROXY and HTTPS_PROXY, then test both package installation and runtime API connectivity separately.

Do I need OpenAI only?#

Not necessarily. Many compatible workflows can point to https://crazyrouter.com/v1 and use other coding-capable models through the same client shape.

What is the most common installation issue?#

Usually it is one of three things: wrong Node version, missing environment variables, or proxy/network restrictions.

Summary#

A good Codex CLI installation guide should help in the environments engineers actually use, not only on a perfect laptop. Install the package, verify Node, configure proxies, and consider a compatible endpoint like Crazyrouter if you want flexibility across coding models instead of one fixed backend.

Related Articles