Codex CLI: install, configure and troubleshoot LYRouter access

Codex CLI can connect to LYRouter as a custom model service. This page starts with the installation prerequisites, then shows how to configure the tool and make your first call.

Already installed? Go straight to Configure LYRouter.

Prerequisites

This page covers connecting Codex CLI through a custom model provider, installed with npm. Choose your operating system and prepare Node.js LTS / npm, network access and write permission to your user-level global installation directory. The model service must support Responses.

1. Choose a terminal environment

You can run Codex CLI natively in PowerShell. If your project and dependencies are in WSL, run it in the WSL terminal and prepare the environment by following the Linux tab. For how Codex runs and is sandboxed on Windows, see the official OpenAI documentation.

2. Prepare Node.js and npm

If they are not installed, first install Node.js LTS for Windows as described in environment setup in Your first model call. Reopen PowerShell, then check:

node --version
npm.cmd --version
npm.cmd config get prefix

Make sure version numbers are shown and the global installation directory is writable. On Windows, use npm.cmd to avoid PowerShell's execution policy restrictions on npm.ps1.

To connect to LYRouter you also need an enabled API key and a model available in the current workspace. Replace MODEL_ID in the examples with an actual system model identifier. Your tool account and your LYRouter account are two separate identities.

Install the app

npm.cmd install -g @openai/codex@latest
codex --version

Reopen the terminal after installation and check the version. For other installation methods, see the official guides below.

Configure LYRouter

Merge the custom provider configuration into ~/.codex/config.toml:

model = "MODEL_ID"
model_provider = "lyrouter"

[model_providers.lyrouter]
name = "LYRouter"
base_url = "https://api.lyrouter.com/v1"
env_key = "LYROUTER_API_KEY"
wire_api = "responses"

In the current official configuration, wire_api supports only responses; do not use the old chat value. Put the key in the environment variable that the configuration names:

export LYROUTER_API_KEY="YOUR_LYROUTER_API_KEY"
codex

The model and its source must actually support Responses. Choosing a Chat-only source makes calls fail.

Verify your first call

Start the app, explicitly select the model you just configured, and send a minimal task such as "Reply OK". Then check the generation endpoint, status and actual model in LYRouter's request logs. A successful connection test does not mean that full generation or tool calling works.

Everyday use and troubleshooting

The command is not found after installation. What should I do?

Answer: Reopen the terminal, run the version check command from this page's installation steps, and check whether the installation directory is on PATH. Use the same terminal and runtime environment as in the installation steps. If it still does not work, check the installation against the official installation guide.

How should I configure the Base URL and the wire protocol?

Answer: On this page, base_url is https://api.lyrouter.com/v1 and wire_api is responses. Make sure the lyrouter provider is selected and the model and its service source support Responses. Do not add /v1 to the address twice.

What should I check before switching models?

Answer: Make sure the new model is enabled in the current workspace, has at least one valid service source, and supports the protocol and tool capabilities the app needs. Use the system model identifier, not the display name.

Why does my configuration stop working after an app update?

Answer: First check the current app version and which configuration location it actually reads, then check the provider, address, key and model against "Configure LYRouter" on this page. The official resources linked on this page define the configuration requirements of each version.

A request returns 401 / 403. What should I check first?

Answer: Make sure you entered an enabled LYRouter API key, and check the model sources and access policies of the workspace the key belongs to. Use the specific error and the logs to find what rejected the request; see 401 / 403: authentication and access.

A request returns 429. Does retrying repeatedly help?

Answer: First find out whether a platform limit or an exhausted upstream quota caused it, then adjust concurrency, call frequency or resource configuration. Retry with bounded backoff instead of retrying immediately and repeatedly; see 429: rate limits and quotas.

The app replies, but I cannot find the request in the LYRouter logs. What should I do?

Answer: Make sure the LYRouter provider and model configured on this page are the ones in effect, and check the gateway address. After verifying with a minimal generation task, search the request logs in the correct workspace by time and key. Listing models alone does not appear in the regular call list.

Official resources

The requirements and installation methods below come from the tool's official documentation. For later versions, the official instructions take precedence.