Editor & Tool Configuration

OpenAI Codex

Run OpenAI Codex via AnyRouter: configure base_url in config.toml and your API key in auth.json or with cc-switch, then use it in the terminal or desktop app.

Use Codex via the AnyRouter API

Installation

Download from the official site (macOS)

https://openai.com/codex/

Install via the command line

npm install -g @openai/codex

Environment configuration

Configure via config files

  1. Edit the ~/.codex/config.toml config file and add the following:
profile = "AnyRouter"

[model_providers.AnyRouter]
name = "AnyRouter"
base_url = "https://anyrouter.win/v1"
personality = "pragmatic"
wire_api = "responses"

[profiles.AnyRouter]
model = "gpt-5.2"
model_provider = "AnyRouter"
model_reasoning_effort = "high"
  1. Edit the ~/.codex/auth.json config file as follows:
{
  "OPENAI_API_KEY": "AnyRouter_API_KEY"
}

Configure via cc-switch

  1. Run CC-Switch and add a provider.
Codex 1
  1. Select "AnyRouter" from the preset list.
Codex 2
  1. Enter your API key in the "API Key" field and click "Add" to save the settings.
Codex 3
  1. Back on the home page, select "AnyRouter" in the provider list and click "Enable" to start using it.
Codex 4

Using Codex

In the terminal

  1. Open a terminal, go to your project directory, and run the codex command.
cd /path/to/your/project
codex
  1. Set permissions as needed.
Codex 5
  1. Choose the model you want to use.
Codex 6
  1. Type a natural-language prompt. If it responds normally, the configuration succeeded.
Codex 8

In the Codex desktop app

  1. Open the Codex desktop app and choose a working directory.
  2. Type a task in the input box. If it responds normally, the configuration succeeded.
Codex 9

Handy Command Reference

Help command

codex -h

Full command options

Usage
  $ codex [options] <prompt>

Options
  -h, --help                 Show help and exit
  -m, --model <model>        Specify the model to use (default: codex-mini-latest)
  -i, --image <path>         Path to a file containing image input
  -v, --view <rollout>       View a previously saved session
  -q, --quiet                Non-interactive mode; print only the assistant's final output
  -a, --approval-mode <mode> Override the approval policy: 'suggest', 'auto-edit', or 'full-auto'

  --auto-edit                Automatically approve file edits; still prompt to confirm commands
  --full-auto                Automatically approve edits and commands in the sandbox environment

  --no-project-doc           Do not automatically include the repo's 'codex.md' file
  --project-doc <file>       Include the specified Markdown file as context
  --full-stdout              Do not truncate the stdout/stderr of command output

Dangerous options
  --dangerously-auto-approve-everything
                             Skip all confirmation prompts and execute commands directly (no sandbox protection)
                             For temporary local testing environments only

Experimental options
  -f, --full-context         Launch in "full context" mode, loading the entire repo into context
                             and applying batch edits in a single pass
                             Only compatible with the --model flag

Examples
  $ codex "Write and run a Python program that prints ASCII art"
  $ codex -q "fix the build issue"

On this page