Настройка 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
2. Install OpenAI Codex CLI
Section titled “2. Install OpenAI Codex CLI”Global install
Section titled “Global install”npm install -g @openai/codexIf you use Homebrew, you can also install it with:
brew install --cask codexVerify installation
Section titled “Verify installation”codex --versionA version number means the installation succeeded.
3. Configure RouteAPI
Section titled “3. Configure RouteAPI”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:
export ROUTEAPI_KEY="ваш ключ RouteAPI"If you use Windows PowerShell:
$env:ROUTEAPI_KEY="ваш ключ RouteAPI"3.2 Write config.toml
Section titled “3.2 Write config.toml”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 consolemodel_provider: tells the session to use the customrouteapiproviderbase_url: always usehttps://www.routeapi.ai/v1env_key: tells Codex to read the key fromROUTEAPI_KEY
3.3 Start Codex
Section titled “3.3 Start Codex”codexFor a more conservative default mode, you can also add these two settings in config.toml:
approval_policy = "on-request"sandbox_mode = "workspace-write"4. IDE integration
Section titled “4. IDE integration”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.
VS Code / Cursor / Windsurf
Section titled “VS Code / Cursor / Windsurf”- Install the official Codex IDE extension
- Restart the editor
- Open the project and start Codex
- If the extension does not read the new configuration immediately, reopen the workspace or restart the editor
JetBrains IDE
Section titled “JetBrains IDE”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.