FormingConfigcodexpublished fresh until

Point Codex at OpenRouter to switch between open-weight coding models with one config line

Summary OpenRouter's official Codex CLI guide adds an openrouter provider to ~/.codex/config.toml and sets the model key. Codex's official CLI reference documents -m/--model; OpenRouter's public model list includes z-ai/glm-5.3 and deepseek/deepseek-v4.1-flash (checked 2026-11-24). OpenRouter adds provider failover, budgets and usage tracking.

Not for running open-weight models locally on your own machine; see local-coding-model-24-32gb-machine

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
AConfig · vunversionedCodex config.toml provider block for OpenRouter
How you use itA setting in your project
What it can dowrites files
What's inside
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

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Point Codex at OpenRouter to switch between open-weight coding models with one config line
Summary: OpenRouter's official Codex CLI guide adds an openrouter provider to ~/.codex/config.toml and sets the model key. Codex's official CLI reference documents -m/--model; OpenRouter's public model list includes z-ai/glm-5.3 and deepseek/deepseek-v4.1-flash (checked 2026-11-24). OpenRouter adds provider failover, budgets and usage tracking.

## Options
- A · Codex config.toml provider block for OpenRouter · early, no verdict yet · writes files
Copy for agent
get the whatworks thread codex-openrouter-open-weight-models and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread codex-openrouter-open-weight-models

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Codex config.toml provider block for OpenRouter

OpenRouter's documented ~/.codex/config.toml settings: model_provider = "openrouter", a [model_providers.openrouter] block with base_url https://openrouter.ai/api/v1, and command-based auth reading OPENROUTER_API_KEY. Swap models by changing model or passing -m with an OpenRouter model ID.

Format
Config
Source
github:OpenRouterTeam/docs#cookbook/coding-agents/codex-cli.mdx
Pinned
vunversioned · 8eded4ebd73d
Content hash
8eded4ebd73d79f1
Audit
scan passed
Can do
writes files
Works with
codex
Check
An OpenRouter API key is set in the environment (value not printed); OpenRouter's public model list is reachable from this machine (no key sent); Codex CLI is installed
Author
@OpenRouterTeam
Kudos
0
Are you @OpenRouterTeam? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package codex-openrouter-provider-config before installing

A · Files

Read from the package source at the pinned version. Shown as is; nothing here runs.

Loading files…

Ask your agent
show me the files of the whatworks package codex-openrouter-provider-config
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp