Codex integration

Run the OpenAI Codex CLI on Modellane models with a custom provider in config.toml that uses the Responses API.

Codex talks to model providers through the OpenAI Responses API. Add Modellane as a custom provider in its config file, set the context window and pick a model.

Codex is OpenAI's coding agent for the terminal. Current versions talk to every model provider through the OpenAI Responses API, which Modellane serves at POST /v1/responses. You add Modellane as a custom provider in the Codex config file.

Configure Codex#

Open ~/.codex/config.toml (create it if it does not exist) and add:

TOML

model = "lane-1"
model_provider = "modellane"
# Replace with the context length of your model from Models & Pricing.
model_context_window = 128000

[model_providers.modellane]
name = "Modellane"
base_url = "https://usemodellane.com/v1"
env_key = "MODELLANE_API_KEY"
wire_api = "responses"
ParamValue
modellane-1, or any id from Models & pricing
base_urlhttps://usemodellane.com/v1
env_keyThe environment variable that holds your key from API keys
wire_apiresponses, the only value Codex accepts

The provider id must not be openai, ollama or lmstudio; Codex reserves those names for its built-in providers.

Then export the key and start Codex:

Shell

export MODELLANE_API_KEY="your-api-key"
codex

Set the context window#

Codex does not fetch the model list or context lengths from a custom provider. For a model it does not know, it assumes a fixed context size, which can be larger than the model really has. Set model_context_window to the context length shown for your model in Models & pricing, so Codex compacts the conversation before it overflows. Without it, long sessions can fail with context_length_exceeded.

Verify#

Send one test prompt without opening the interactive view:

Shell

codex exec "Reply with the word ready."

A reply means the provider, key and model are set up. A 401 points at the key, and model_not_found at the model id.

What works and what does not#

  • Works: chat, streaming, reasoning summaries on models that reason, function tools, MCP tools and the free-form tools Codex uses for editing files.
  • Hosted tools are skipped: web search and other tools that run on OpenAI's servers are removed from the request without an error, so the model works without them.
  • No stored responses: Codex sends the full conversation with every request, which is what Modellane needs. previous_response_id is not supported.
  • Reasoning settings: model_reasoning_effort and similar options have no effect; models that reason do so on their own, and reasoning is billed as output tokens.
  • Free-form tools such as the file patch tool get their grammar as a hint only, so a model can produce a patch that does not apply. Models with strong tool use make this rare.

The Responses API guide lists every supported field.

Images#