Search docs...

Start typing to search documentation

Codex
Codex CLI

OpenAI Codex CLI Setup Guide

Install and configure Codex CLI with UnoRouter on Windows, macOS, and Linux.

Overview

Codex CLI is OpenAI's terminal coding agent. It reads, writes, and runs code through sandboxed, reviewable patches. Point its custom provider at UnoRouter's base URL to use any model in the catalog.

Quick Config

Paste these into the client. Your key auto-fills when signed in.

text
Base URL: https://api.unorouter.com/v1
API Key: YOUR_API_KEY

Sign in to auto-fill your API key

Compatibility

Chat CompletionsResponses APIStreamingTool calling

Step-by-step setup

  1. 1
    Install Codex CLI

    Install Codex CLI globally with npm.

    bash
    npm install -g @openai/codex

    Sign in to auto-fill your API key

  2. 2
    Configure the model provider

    Edit `~/.codex/config.toml`. Set your model id and add a custom provider with UnoRouter's base URL using the responses wire API.

    toml
    # ~/.codex/config.toml
    model = "YOUR_MODEL_ID"
    model_provider = "unorouter"
    
    [model_providers.unorouter]
    name = "UnoRouter"
    base_url = "https://api.unorouter.com/v1"
    wire_api = "responses"

    Sign in to auto-fill your API key

  3. 3
    Add your API key

    Write your UnoRouter API key into `~/.codex/auth.json`.

    json
    // ~/.codex/auth.json
    {
      "OPENAI_API_KEY": "YOUR_API_KEY"
    }

    Sign in to auto-fill your API key

  4. 4
    Start Codex

    Run `codex` in your project directory.

powershell
$env:OPENAI_BASE_URL="https://api.unorouter.com/v1"
$env:OPENAI_API_KEY="YOUR_API_KEY"

codex

Sign in to auto-fill your API key

Recommended models

Free models that work here. Paste any model id into the client.

ox-alpha:freeglm-5.3-search:freeglm-5.3-think-search:freeglm-5.3-thinking:freeglm-5.3:free

Gotchas

  • On an unsupported endpoint error, confirm `wire_api` is `responses` and the base URL ends in `/v1`.
  • A 401 means the key in `~/.codex/auth.json` is missing or stale. Paste a fresh key from your UnoRouter dashboard.
  • If Codex ignores your provider, check the table name in `config.toml`. Provider IDs allow underscores, not hyphens (`model_providers.my_provider`, never `my-provider`). `openai` is reserved and cannot be overridden.
Generate API KeyModels