- How you use it
- A setting in your project
- What it can do
- writes files
- What's inside
The option
| Option | AConfig · vunversionedCodex config.toml provider block for OpenRouter |
|---|---|
| How you use it | A setting in your project |
| What it can do | writes files |
| What's inside |
What this thread does
OpenRouter documents two ways to run Codex on its API (read 2026-11-24):
1. Manual config (Codex CLI cookbook): set model_provider = "openrouter" and add a [model_providers.openrouter] block with base_url https://openrouter.ai/api/v1 and a command-based auth block that echoes $OPENROUTER_API_KEY. OpenRouter recommends the command form over env_key because it lets Codex fetch the OpenRouter model catalog; with env_key, non-OpenAI models trigger an unknown-model warning. Put these settings in your user Codex config or a profile file there: Codex ignores model_provider and model_providers in a project's .codex/config.toml, so a repository can't redirect your credentials (checked in the Codex source, 2026-11-24). 2. Ori (Ori Harness): OpenRouter's own CLI. ori codex --model <id> starts Codex on OpenRouter with an OAuth login, and ori harness setup codex / ori harness reset codex switches the config. It installs through a curl-to-shell script.
As of November 2026, Codex CLI 0.165.0 (released October 27) stops retrying when a provider reports a model was not found and preserves that provider error (checked 2026-11-24).
Routing options: OpenRouter routes each model across providers and can fail over between them. Its Responses API documentation also offers model fallback lists and a Pareto Router (openrouter/pareto-code) that picks the cheapest available coding model within a selected quality tier. We have not verified those through Codex's Responses API.
Open-weight coding models in the public OpenRouter model list, checked 2026-11-24, include z-ai/glm-5.3, deepseek/deepseek-v4.1-flash, liquid/lfm-2.5-24b-a2b and prism-ml/ternary-bonsai-2-27b. Check current prices on openrouter.ai/models. Your prompts and code go to OpenRouter and its upstream providers.
Primary source
Primary source: OpenRouter Codex CLI cookbook (OpenRouter, read 24 November 2026). Checked: model_provider = "openrouter", the [model_providers.openrouter] block with base_url https://openrouter.ai/api/v1, command-based auth that echoes $OPENROUTER_API_KEY, and the reason it prefers that over env_key (Codex then does not fetch the model catalog and non-OpenAI models show an unknown-model warning). The cookbook sets the model through the model key in config.toml and does not mention -m itself, which the official Codex CLI reference documents as -m/--model. The example model IDs above come from the OpenRouter models API, not the cookbook (checked 2026-11-24). Also checked 2026-11-24: the linked Ori harness commands, Pareto Router and fallback-list documentation, and the linked Codex source for the project-config claim. Not verified end to end through Codex: Ori setup, model availability for a particular account, or Pareto routing and fallback lists.
Started from a post by @OpenRouterTeam, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.