How to Install Codex CLI on Linux, macOS & Windows (Custom API Key)

Step-by-step guide to install OpenAI Codex CLI on Linux servers, SSH/remote sessions, macOS, and Windows PowerShell — plus config.toml for Modelseed Responses API (GPT-6.2 Sol & Astra).

Modelseed ·
INTERACTIVE CONFIG WIZARD

Generate a ready-to-paste config in 5 seconds

Pick your client, OS, and model — then click below to sign up and auto-fill this exact snippet with a scoped Starter API Key.

# %USERPROFILE%\.codex\config.toml
# Recommended key cap: $2 (2,000 credits)
model = "gpt-6.2-sol"
model_provider = "modelseed"

[model_providers.modelseed]
name = "Modelseed"
base_url = "https://api.modelseed.dev/v1"
wire_api = "responses"
env_key = "MODELSEED_API_KEY"
requires_openai_auth = false

# PowerShell:
$env:MODELSEED_API_KEY = "sk-YOUR_MODELSEED_KEY"
codex
30-SECOND API QUICK START

deepseek-v4-1-flash · Input $0.0822 · Output $0.3289 per 1M tokens

Get key + bonus
from openai import OpenAI
client = OpenAI(base_url="https://api.modelseed.dev/v1", api_key=os.environ["MODELSEED_API_KEY"])
res = client.chat.completions.create(model="deepseek-v4-1-flash", messages=[{"role":"user","content":"Hello!"}])
Starter bonus: $0.20–$1.00 (200–1,000 credits) + +10% first-payment bonus · Lava from $1, USDT & Binance Pay · DeepSeek rates · Pricing calculator

Install Codex CLI in 60 seconds (Node.js 22+ on Linux, macOS, Windows)

Codex CLI runs cleanly on local laptops as well as headless Linux VPS and SSH remote-control environments where browser OAuth login is inconvenient or blocked by region errors. Installing via npm and authenticating with a Modelseed API key eliminates browser OAuth handshakes entirely.

You only need Node.js 20/22+, a Modelseed API key (with $0.20–$1.00 starter credits included on verified signup), and an 8-line ~/.codex/config.toml pointing to https://api.modelseed.dev/v1.

  1. Verify Node.js 20+ (node -v). On Ubuntu/Debian Linux servers, install Node 22 LTS via NodeSource or nvm.
  2. Install Codex CLI globally: npm install -g @openai/codex.
  3. Write ~/.codex/config.toml with wire_api = "responses" and base_url = "https://api.modelseed.dev/v1".
  4. Export MODELSEED_API_KEY and launch codex inside any git repository.
Linux / macOS / Remote SSH — Install & configure Codex CLI
# 1. Install Codex CLI globally
npm install -g @openai/codex

# 2. Write ~/.codex/config.toml
mkdir -p ~/.codex
cat > ~/.codex/config.toml <<'EOF'
model_provider = "modelseed"
model = "gpt-6.2-sol"

[model_providers.modelseed]
name = "Modelseed"
base_url = "https://api.modelseed.dev/v1"
env_key = "MODELSEED_API_KEY"
wire_api = "responses"
EOF

# 3. Export API key and run (works over SSH / tmux / remote Linux)
export MODELSEED_API_KEY="sk-your-modelseed-key"
codex "Audit package.json scripts and add a fast typecheck target"

Headless Linux, SSH & Remote-Control Codex tips

When running Codex CLI on remote Linux build boxes, CI runners, or over SSH/tmux, browser-based login flows often fail or expire. API-key authentication via env_key = "MODELSEED_API_KEY" works deterministically in headless terminals.

  • Run inside tmux or screen so long multi-file refactors survive SSH disconnects.
  • Use codex exec "..." for non-interactive headless tasks and CI pipelines.
  • Bind a per-machine API key with a $5 safety cap in Modelseed Console so remote servers never hold an uncapped master key.

Windows PowerShell one-liner & GPT-6.2 catalog rates

On Windows, set MODELSEED_API_KEY persistently with setx or in your PowerShell $PROFILE, and write %USERPROFILE%\.codex\config.toml with UTF-8 encoding.

Modelseed GPT Responses API routes for Codex CLI (USD per 1M tokens)
Model IDInput ≤272KOutput ≤272KCache ReadBest For
gpt-6.1-terra$0.0321$0.1604$0.0015Ultra-cheap lint/test loops
gpt-6.2-sol$0.0642$0.3208$0.0032Daily interactive coding (default)
gpt-6.2-astra$0.2567$1.2833$0.0128Complex architecture & debugging

Frequently asked questions

Does Codex CLI on Linux require a browser login when using Modelseed?

No. Setting env_key = "MODELSEED_API_KEY" in ~/.codex/config.toml authenticates directly via Bearer token with zero browser redirects, ideal for SSH and Docker containers.

How do I fix 403 unsupported_country_region_territory in Codex CLI?

Switch model_provider in ~/.codex/config.toml to modelseed (https://api.modelseed.dev/v1). Requests route through Modelseed with standard Responses API compatibility and no region billing blocks.

How much does a typical Codex CLI coding day cost on gpt-6.2-sol?

With prompt caching active ($0.0032/1M cache reads), heavy interactive sessions of 1,500+ requests routinely consume only a few dollars of credit.

Can I switch between gpt-6.2-sol and gpt-6.2-astra on the fly?

Yes. Pass --model gpt-6.2-astra on any single Codex CLI command or update model = "..." in ~/.codex/config.toml.

Official references

BUILD WITH MODELSEED

From an idea to your first request.

One key and a familiar API. New verified accounts receive a $0.20–$1.00 welcome bonus (200–1,000 credits, 30 days) + 10% bonus on their first payment.

Get API key + bonus