anyr codex

Route Codex through AnyRouter with one CLI command, or set two environment variables yourself.

Route Codex through AnyRouter for one key, unified billing and request logs across every model.

Setup

bash
anyr codex

The first run signs you in (browser, or device code on SSH/headless; --key, --paste and --device force a path, see Login). The key is saved to ~/.anyrouter/config.yaml and shared with anyr claude.

bash
anyr codex --model auto --effort xhigh   # model and reasoning depth
anyr codex --model auto -- exec          # flags after -- go to Codex
anyr codex --dry-run                     # print resolved environment, run nothing

See the configuration reference for all flags.

MCP tools

anyr codex connects the AnyRouter MCP gateway with the session's key when Auto-connect in coding agents is on in the dashboard. Turn it off with --no-mcp, anyr mcp auto off, or in the dashboard.

Verify

Run codex "hello" or anyr codex "hello"; the request appears in your usage dashboard with cost, latency and tokens. anyr codex --dry-run shows the base URL and model first.

Troubleshooting

SymptomFix
401 or auth errorsManual: check echo $OPENAI_API_KEY in the current shell. CLI: anyr config get to confirm a stored key, or re-run anyr setup.
Requests still hit OpenAIecho $OPENAI_BASE_URL must print https://anyrouter.dev/api/v1 (note /v1).
Model not foundCodex uses Chat Completions; pick a Chat-Completions-compatible model.

AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer