Codex CLI Setup Guide (Terminal CLI)

Install Codex CLI in your terminal and connect to platform API

1

Install Codex CLI

Install Codex CLI globally via npm (requires Node.js 22+).

npm install -g @openai/codex
2

Configure config.toml

Create or edit ~/.codex/config.toml to configure the platform API connection.

# ~/.codex/config.toml
model_provider = "custom"
model = "gpt-5.1-codex"
model_reasoning_effort = "high"

[model_providers.custom]
name = "custom"
base_url = "/api/v1"
env_key = "OPENAI_API_KEY"
3

Set API Key

Export the API key environment variable in your shell profile (~/.zshrc or ~/.bashrc).

export OPENAI_API_KEY="your-api-key"
4

Launch Codex

Navigate to your project directory and run the codex command to start the coding agent.

cd your-project
codex