aimldocs
Integrations

Codex

Add ai.ml to OpenAI's Codex CLI as a model provider using the Responses API.

Codex speaks only the OpenAI Responses API. ai.ml serves it at /v1/responses.

With the CLI

npx @aiml/cli setup codex

By hand

Add this to ~/.codex/config.toml (or $CODEX_HOME/config.toml), and export your key as AIML_API_KEY. Codex reads provider keys only from the environment.

cookbook/integrations/codex/config.toml
model_provider = "aiml"
model = "gpt-5"
web_search = "disabled"

[model_providers.aiml]
name = "ai.ml"
base_url = "https://api.ai.ml/v1"
env_key = "AIML_API_KEY"
env_key_instructions = "Create a key in the ai.ml console, then run `npx @aiml/cli setup codex`."
wire_api = "responses"
  • Put this in your user file. A project's .codex/config.toml cannot define providers.
  • wire_api = "responses" is the only value Codex accepts. It removed "chat".
  • web_search = "disabled" turns off the hosted web-search tool Codex offers by default. ai.ml routes a request carrying that tool only to a model whose provider runs it, and refuses it everywhere else. For such a model, set it to "cached".

Models

Name any catalog model in model. Codex looks up its own metadata by name, and ai.ml's names are not in Codex's catalog, so Codex prints Model metadata … not found and uses its defaults:

  • a 272k-token context window;
  • no freeform apply_patch tool. Codex edits files through its shell tool instead.

Set model_context_window if your model's window is smaller.

What to expect

  • Codex sends its agent tools, and every MCP server's tools, grouped under a namespace. ai.ml gives each tool a name every provider accepts, and returns each call under the namespace and name Codex offered.
  • Every request carries the whole conversation (store: false). ai.ml keeps no state between calls, which is what Codex expects of a custom provider.
  • Freeform (custom) tools are not supported yet. Codex only offers them to models in its own catalog.

Verified with Codex 0.159.2.

On this page