Back to Blog
EnglishTutorial

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

A Codex CLI installation guide for real developer environments, including WSL, remote containers, proxy settings, troubleshooting, and multi-model fallback options.

C
Crazyrouter Team
March 21, 2026 / 2196 views
Share:
Codex CLI Installation Guide 2026 for WSL, Devcontainers, and Proxies

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.

Implementation Guides

Podcast

AI Dev Tools: The Crazyrouter Podcast

Short episodes for developers on AI APIs, gateways, cost control and coding tools.

Latest episodes

  • EP196 · Oct 29, 2026 · 6:53

    AI API Security Posture — Turn Controls Into Continuous Evidence

    A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.

  • EP195 · Oct 28, 2026 · 7:21

    AI API Policy Drift — Detect When Production Rules Stop Matching Intent

    A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.

Episodes with written show notes →

Related Articles

Codex CLI Installation Guide 2026 for Proxies, Remote Dev, and DevcontainersTutorial

Codex CLI Installation Guide 2026 for Proxies, Remote Dev, and Devcontainers

A practical Codex CLI installation guide for 2026 covering macOS, Linux, Windows, proxies, devcontainers, environment variables, and post-install API setup.

Mar 24
Gemini CLI User Guide - Google AI in Your TerminalTutorial

Gemini CLI User Guide - Google AI in Your Terminal

Complete guide to install and configure Gemini CLI, Google's open-source command-line AI tool. Learn how to set up proxy, use built-in tools

Jan 24
How to Use JEV 1.13: From Customer-Service Triage to Agent Routing, a Hands-On Test of This Low-Cost Decision ModelTutorial

How to Use JEV 1.13: From Customer-Service Triage to Agent Routing, a Hands-On Test of This Low-Cost Decision Model

JEV 1.13 excels at turning natural language into choices, probabilities, and scores that programs can use directly. Using real-world calls for Chinese customer-service triage, refund decisions, and RAG filtering, this article explains the three usage patterns—Choice, Noul, and Score—and guides you through 12 editable scenarios in the Crazyrouter JEV Decision Playground, where you can inspect results and copy API integration code.

Sep 23
Model Distillation in Python: Fit a Tiny Student to Soft Teacher LabelsTutorial

Model Distillation in Python: Fit a Tiny Student to Soft Teacher Labels

An executable two-parameter student learns probabilities from a synthetic teacher. Nine training inputs, four held-out points and four checks illustrate distillation without claiming an LLM was trained.

Mar 30
Streaming API Implementation Guide 2026: SSE, WebSockets, and Real-Time UX PatternsTutorial

Streaming API Implementation Guide 2026: SSE, WebSockets, and Real-Time UX Patterns

A practical streaming API implementation guide for developers building AI apps with SSE, WebSockets, partial tokens, and resilient frontends.

Mar 18
Can Claude Code Build a World Cup 2026 Match Predictor? A Real Crazyrouter API TestTutorial

Can Claude Code Build a World Cup 2026 Match Predictor? A Real Crazyrouter API Test

We built a reproducible World Cup 2026 match predictor demo with Claude Code-style workflow, Elo/Poisson probabilities, charts, and real Crazyrouter API calls through https://cn.crazyrouter.com/v1.

Jun 12