Skip to content
EN

Use OpenRouter with Codex from the terminal

Connect your OpenRouter account once, then choose its model when launching Codex. You need the Mandri CLI and an OpenRouter API key. Model requests use your OpenRouter account and its billing limits.

Terminal window
mandri provider add openrouter

Paste your key at the provider API key: prompt. The key is entered interactively rather than included in the command. Mandri verifies the connection before saving it.

If you already registered this name, check the existing connection:

Terminal window
mandri provider verify openrouter

To add a different OpenRouter account, use a distinct name and specify its type:

Terminal window
mandri provider add second-router --kind openrouter
Terminal window
mandri provider models openrouter

Choose a model intended for tool use. Replace <model-id> with its exact ID, keeping any slashes inside it:

Terminal window
mandri run --model "openrouter/<model-id>" codex

Run this command from your project folder. Codex is included with Mandri. Enter your task when its terminal interface opens.

For Pi, install it using the official instructions, make sure pi is available on your PATH, then use:

Terminal window
mandri run --model "openrouter/<model-id>" pi

OpenRouter and the provider serving the model receive the model requests. Available capabilities depend on the selected model and tool. The OpenRouter Codex guide describes model compatibility; Mandri supplies the connection configuration for the commands above.

Verification fails: check the key’s status in OpenRouter and read the error in the terminal.

The model is listed but the task fails: check its availability, tool use support, your account balance and key limits. Listing models does not test a coding task.

For the graphical interface, use OpenRouter in the app.