본문으로 건너뛰기

Codex CLI

Connect OpenAI's terminal coding agent Codex CLI to PleumRouter's Responses API.

Codex CLI is OpenAI's coding agent that reads and edits code and runs commands from the terminal. Codex dropped the Chat Completions path and speaks only the Responses API (/v1/responses), so your config needs wire_api = "responses". For the desktop app, see Codex Desktop.

Quick start#

  1. Install Codex CLI

    Skip this if it is already installed.

    Terminal
    npm i -g @openai/codex
    codex --version
  2. Create an API key

    In the dashboard's API keys page, create a key that starts with plm_ and copy it. Set daily, weekly or monthly budgets on it while you are there.

  3. Connect to PleumRouter

    Pick one of the three.

    pleum launch

    Leaves `~/.codex` alone and uses a temporary config for this run only.

    npm i -g pleumrouter
    pleum login            # sign in with the browser
    pleum launch codex     # applies the PleumRouter provider for this run only
  4. Run it and check

    A reply to one prompt means you are connected. A 401 points at the key; a 404 points at the /v1 in base_url.

    Terminal
    cd your-project
    codex

Why use PleumRouter with Codex CLI?#

  • Pay only for what you use from prepaid credits. Credits are deducted separately from the tool maker's subscription.
  • Set budgets and limits per key. Daily, weekly and monthly budgets, model allow-lists and team budgets help you manage what an agent spends.
  • One key, many models. Pick Claude, GPT, Gemini or open models; automatic retries and fallback cover provider outages; usage shows up in the dashboard.

How it works#

Codex CLI posts OpenAI Responses API requests (POST /v1/responses) to {base_url}/responses. PleumRouter accepts them, converts function tools, input images and reasoning effort, forwards them to the provider of the model you chose, and returns Responses-format output, including streaming SSE. Auth is the variable named by env_key, or a plm_ key in the Authorization: Bearer header under http_headers.

Configuration reference#

SettingNotes
modelgpt-6-solA model ID from the PleumRouter catalog.
model_reasoning_effort"high"Reasoning effort (low, medium, high, xhigh). Applies where the model supports it.
model_provider"pleum"Points at the [model_providers.pleum] block below.
base_urlhttps://apirouter.pleum.ai/v1Ends at /v1. Codex appends /responses, so dropping /v1 or doubling it gives a 404.
wire_api"responses"Chat Completions was removed from Codex; only Responses is used.
env_key"PLEUM_API_KEY"Name of the shell variable that holds the key. For a CLI started from a shell.
http_headers.Authorization"Bearer plm_xxxxxxxxxxxxxxxx"Puts the key in the file directly. This is what pleum wire codex writes.
supports_websocketsfalsePleumRouter does not support the Responses WebSocket transport, so turn it off.

Choosing models#

Put a PleumRouter catalog ID in model. Look up exact IDs in the model catalog or with GET /v1/models. Add @provider (as in gpt-6-sol@openai) to send to that provider only — this turns off automatic fallback to other providers. For reference, pleum launch codex does not pin a model unless you pass --model, so Codex follows its own model setting. pleum wire codex writes gpt-6.1-sol as model.

These steps assume OpenAI models. Other makers' models connect over the Responses format too, but tool-calling quality can vary by model.

Compatibility#

FeatureStatusNotes
Streaming (SSE)YesEmits response.output_item.done and response.completed events.
Function tool callingPartialOnly function tools are converted; other tool types are skipped.
Image inputYesinput_image is converted. The model must accept images.
Reasoning effortYesThe model_reasoning_effort value is passed on and applies where the model supports it.
Built-in tools (web_search etc.)NoNot supported; they are skipped in the request.
Server compact (/v1/responses/compact)NoAlways returns 501. Use Codex's local compact.
WebSocket transportNoKeep supports_websockets = false.

Troubleshooting#

SymptomCause and fix
401 UnauthorizedThe variable named by env_key is empty, or the key in http_headers is wrong. Run echo $PLEUM_API_KEY in your shell and check it is a plm_ key.
401 on WindowsSet the user-wide variable with setx, then fully quit and reopen Codex (including the desktop app). Terminals and apps that were already open do not see the new variable.
404 Not FoundCheck that base_url is https://apirouter.pleum.ai/v1. Most of the time /v1 is missing or doubled.
model not found / Unknown modelmodel is not in the catalog. Confirm the exact ID with GET /v1/models.
A Model metadata … not found warning appearsThe ID is not in Codex's built-in model list, so it falls back to default metadata. It still works, but values such as context length use defaults and performance can suffer.
The connection keeps dropping or shows reconnectingsupports_websockets = false may be missing. Add it to the provider block and run again.
The config is ignoredPut the provider settings in ~/.codex/config.toml in your home folder, not in a file inside the project. pleum launch passes a temporary config, so it applies to that run only and is not saved to ~/.codex/config.toml.
The web search tool does not workBuilt-in tools such as web_search are not supported. Use an MCP server or a shell tool for web access.
Conversation compaction failsServer compact returns 501. Use Codex's local compact.

Cost & security tips#

  • Set a budget on the key. A coding agent calls the model many times per task and resends long context. Daily, weekly or monthly budgets on your API key make costs easier to predict.
  • Keep the key out of git. Make sure a key in your shell profile or config file never gets committed, and if you suspect a leak, revoke it in the dashboard and issue a new one.
  • Check where sensitive code goes. Prompts and code are sent to the provider of the model you pick. Use Data residency and PII masking to control that.