Skip to content

Настройка Codex

1. OpenAI Codex CLI overview and requirements

Section titled “1. OpenAI Codex CLI overview and requirements”

OpenAI Codex CLI is a local coding agent from OpenAI. It can understand repositories, edit code, run commands, and work with editors such as VS Code, Cursor, and Windsurf.

Before you start, prepare:

  • A working terminal environment
  • Node.js 16 or later
  • An API key created in the RouteAPI console
  • An OpenAI protocol model available in the RouteAPI console
Terminal window
npm install -g @openai/codex

If you use Homebrew, you can also install it with:

Terminal window
brew install --cask codex
Terminal window
codex --version

A version number means the installation succeeded.

The user-level Codex configuration file is ~/.codex/config.toml. On Windows, it usually maps to %USERPROFILE%\.codex\config.toml.

3.1 Configure the API key environment variable

Section titled “3.1 Configure the API key environment variable”

If you use bash, zsh, or sh on macOS / Linux / WSL:

Terminal window
export ROUTEAPI_KEY="ваш ключ RouteAPI"

If you use Windows PowerShell:

Terminal window
$env:ROUTEAPI_KEY="ваш ключ RouteAPI"
model = "имя вашей модели"
model_provider = "routeapi"
[model_providers.routeapi]
name = "RouteAPI"
base_url = "https://www.routeapi.ai/v1"
env_key = "ROUTEAPI_KEY"
wire_api = "responses"

In this configuration:

  • model: enter an OpenAI protocol model name available in the RouteAPI console
  • model_provider: tells the session to use the custom routeapi provider
  • base_url: always use https://www.routeapi.ai/v1
  • env_key: tells Codex to read the key from ROUTEAPI_KEY
Terminal window
codex

For a more conservative default mode, you can also add these two settings in config.toml:

approval_policy = "on-request"
sandbox_mode = "workspace-write"

After config.toml is complete, Codex IDE extensions can usually reuse the same configuration, so you do not need to enter the RouteAPI address and key again in the editor.

  1. Install the official Codex IDE extension
  2. Restart the editor
  3. Open the project and start Codex
  4. If the extension does not read the new configuration immediately, reopen the workspace or restart the editor

For IntelliJ IDEA, PyCharm, WebStorm, GoLand, and other JetBrains IDEs, finish the CLI configuration first, then follow the Codex guide in the IDE. This keeps terminal and IDE usage on the same RouteAPI configuration.