Skip to main content

Overview

Type: Coding ToolPrimary Path: OpenAI Responses (advanced optional path)Support Confidence: Supported with model/path limits
OpenAI Codex is an open-source command-line tool (CLI) that serves as a lightweight coding agent, capable of reading, modifying, and running code in the terminal. It’s built on GPT models and optimized for code generation. For AI Sonar, Codex CLI can use /v1/responses, but you should treat it as an advanced compatibility path. Some Responses-only features are not guaranteed across every model and routed path. Codex CLI remote compaction is supported on POST /v1/responses/compact. Codex sends the current session model in body.model for /compact and auto-compact, so keep the model you want to compact with available on the Responses path; do not configure /v1/compact.

System Requirements

  • OS: macOS, Linux (official support), Windows via WSL
  • Node.js: Version 18+
  • npm: Version 10.x.x or higher

Installation

Verify installation:

Configuration

Step 1: Set API Key

Temporary (current session):
Permanent configuration: Add to ~/.bashrc, ~/.zshrc, or ~/.bash_profile:
Then reload:

Step 2: Configure config.toml

Edit ~/.codex/config.toml:
This WebSocket mode is a Responses-over-WebSocket bridge for Codex clients. It accepts only official response.create events; stream is implicit, and background and response.cancel are not available on this transport. It is not the OpenAI Realtime API and does not accept session.update, conversation.item.*, input_audio_buffer.*, binary audio, or nested Realtime response.create.response envelopes.
If the config file doesn’t exist, run codex once to generate it, then edit the file. Restart Codex completely after changing config.toml so the new provider settings are reloaded.
Codex is deprecating chat/completions support for custom providers. Keep wire_api = "responses" for AI Sonar unless you are intentionally using an older compatibility path.
AI Sonar forwards unknown Responses fields best-effort without silently downgrading the request to Chat Completions. The selected service decides whether a field or combination is supported.

Basic Usage

Start interactive mode:
Direct command:
Specify model:

Interactive Commands

Verify Configuration

Common Use Cases

Code review:
Generate commit messages:
Fix errors:
Explain code:

Troubleshooting

  • Verify base_url in config.toml is exactly https://api.aisonar.dev/v1
  • Check network connectivity
  • Ensure no proxy interference
  • Verify env_key = "OPENAI_API_KEY" is present in ~/.codex/config.toml
  • Verify OPENAI_API_KEY environment variable is set
  • Check that the key starts with sk-
  • Ensure the key is active in AI Sonar dashboard
  • Some fields are only available on /v1/responses when AI Sonar can guarantee that behavior for the selected model and route
  • If you see unsupported_request_field, remove that field or switch to a workflow that does not depend on it
  • Codex CLI calls POST /v1/responses/compact, not /v1/compact
  • The compaction request uses the current session model, so that model must be available on the Responses path
  • Keep wire_api = "responses" and base_url = "https://api.aisonar.dev/v1"