Skip to main content

Codex CLI

Codex CLI is a programming terminal agent launched by OpenAI that runs locally on your computer.
  1. Installation
Run the following command in your terminal to install Codex CLI.
npm install -g @openai/codex

macOS users can use Homebrew:
brew install codex
  1. Configure to use platform models (macOS/Linux)
Open ~/.codex/config.toml and add the following configuration:
model = "gpt-5"
model_provider = "myrouter"

[model_providers.myrouter]
name = "Myrouter using Chat Completions"
base_url = "https://api.myrouter.ai/openai/v1"
env_key = "OPENAI_API_KEY"
wire_api = "chat"
query_params = {}
For more detailed configuration options, refer to the official documentation.
  1. Run Codex CLI
Set your API Key from this site as an environment variable and run codex:
OPENAI_API_KEY=<API_KEY> codex

Codex VSCode Extension

You can also use Codex in VSCode. First, configure ~/.codex/config.toml as described in the previous section, then run the following commands:
{
cat << 'EOF' | tee $HOME/.codex/pcodex.sh
#!/bin/bash
OPENAI_API_KEY=sk_xxx /opt/homebrew/bin/codex "$@"
EOF
chmod +x $HOME/.codex/pcodex.sh
}
Then add the following configuration to your VSCode settings.json:
{
    "chatgpt.cliExecutable": "/home/path/.codex/pcodex.sh"
}
Note: Please replace /home/path with your actual home directory path.