Codex CLI
Codex CLI speaks the Responses API and no other format. Waibee Router accepts this format on POST /v1/responses, so Codex connects to it through its own config, with no changes to the client itself.
Configuration
Section titled “Configuration”Add the provider to ~/.codex/config.toml:
model = "openai/gpt-5.1-codex"model_provider = "waibee"model_reasoning_effort = "low"
[model_providers.waibee]name = "Waibee"base_url = "https://api.waibee.com/v1"env_key = "WAIBEE_API_KEY"wire_api = "responses"Define the provider in ~/.codex/config.toml specifically. Codex does not read the model_provider and model_providers keys from a project’s .codex/config.toml, and in a trusted project it warns about this at startup.
model_reasoning_effort is required here. Some reasoning models cannot run with reasoning turned off. If the config does not set an effort level, Codex sends the request without one. Such a model reads that as a request to turn reasoning off and rejects it:
{"error": {"code": "provider_bad_request", "message": "Reasoning is mandatory for this endpoint and cannot be disabled."}}Pick a level the model supports; for openai/gpt-5.1-codex these are low, medium, and high.
export WAIBEE_API_KEY="sk_live_..."codexOn Windows, set the variable with setx WAIBEE_API_KEY "sk_live_...". It appears only in new terminal windows, so start Codex from a new window.
| Field | What it holds |
|---|---|
base_url | The base URL with the /v1 suffix. The client adds the /responses path itself. |
env_key | The name of the environment variable Codex reads the key from. The key itself does not go in the config. |
wire_api | Only "responses", which is also the default. With "chat", Codex does not start: it no longer has that option. |
Choosing a model
Section titled “Choosing a model”model takes an ID from the catalog in the form provider/model. A model being in the catalog does not guarantee that it supports Responses.
model = "anthropic/claude-sonnet-5"To set the model for one run, use the flag:
codex --model anthropic/claude-sonnet-5The reasoning level is set by model_reasoning_effort from the configuration above, for example low, medium, or high. The router passes the value to the model as is.
Context window
Section titled “Context window”Codex has no table of context windows for catalog models. For a model it does not know, it assumes a window of 272,000 tokens, and that number decides when the client starts compacting the session history. If the model’s window is smaller, declare it yourself, using the model’s context_length from the catalog. For example, for a model with a 200,000-token window:
model_context_window = 200000This key cannot raise the window above 272,000: for a model it does not know, Codex caps the value at that limit.
Codex has no setting for the maximum response length: its config has no key like model_max_output_tokens.
Checking the setup
Section titled “Checking the setup”codex exec "Say OK and nothing else"If the model replies, the setup works.
Token usage
Section titled “Token usage”Codex resends the whole conversation on every turn. The router does not store history, and Codex does not use server-side state, so a long session is billed as many requests with growing input.
Prompt caching softens this: from the second turn on, the unchanged beginning of the conversation is billed at a reduced price. In a typical session most of the input is cached, and you can see it in the response:
"usage": { "input_tokens": 9492, "input_tokens_details": {"cached_tokens": 9344}, "output_tokens": 10}Web search
Section titled “Web search”By default, Codex puts the built-in web_search tool in every request. The router runs the search: Codex receives a response built from the results, along with a waibee:web_search item that holds the query and the list of sources. Codex calls its own tools as usual, and the search does not interfere with them.
Successful searches are billed separately from tokens. If you do not need search, remove the tool with the line web_search = "disabled" in ~/.codex/config.toml.
How many searches the model makes, what they cost, and what happens when search is unavailable: Web search.
Troubleshooting
Section titled “Troubleshooting”Model metadata for ... not found at startup. Codex keeps its own table of known models, and our IDs are not in it. The warning is about that table, not about the router’s response: requests go through, tools are called, and responses arrive. Along with the metadata, Codex also loses the model’s real context window. See Context window.
You cannot get rid of the warning by replacing env_key with a [model_providers.waibee.auth] block that runs a command: Codex then tries to refresh the model catalog in its own format, fails to parse our response, and prints it in full to the log. The warning stays anyway. Keep env_key.
codex exec refuses to run outside a git repository. Add --skip-git-repo-check or run it inside a repository.
HTTP 400 with feature_not_supported. The request uses an unsupported feature, or the model does not work on Responses. The response names the reason. Details: Responses format.
HTTP 402. Your balance does not have enough funds; see Errors.
Next steps
Section titled “Next steps”- Responses format: the format itself, streaming, tool calling
- Errors: codes and what to do about them
- Limits: maximum sizes and request rate