Tools

Codex CLI

OpenAI's CLI agent for terminal tasks. Connects over the /v1/responses endpoint through its own profile — your own key and catalog models, your main Codex setup stays untouched.

Codex CLI speaks only the OpenAI Responses API: since February 2026, wire_api = "chat" is a startup error. The ApiMira gateway answers POST /v1/responses directly, so Codex connects without any translating proxy: a provider entry in config.toml plus a separate profile file, while plain codex with your existing settings keeps working as before.

What you need

Base URL
https://apimira.com/v1
API key
am-YOUR_KEYCreated in the dashboard, the API keys section. The full value is shown once.
Model ID
google/gemini-3.7-flashCopy it from the catalogue in full, including the prefix before the slash.

How to connect

  1. 1Add the [model_providers.apimira] table from the first tab to ~/.codex/config.toml: base_url is the gateway address including /v1, env_key names the environment variable holding your key, wire_api = "responses". Leave the rest of the file as it is.
  2. 2Next to it, create the profile file ~/.codex/apimira.config.toml from the second tab: model_provider = "apimira", model set to a catalog ID, web_search = "disabled" and multi_agent = false. Codex 0.134 and newer keeps profiles in separate files; a [profiles.apimira] table inside config.toml makes --profile fail.
  3. 3The web_search = "disabled" line is mandatory: the gateway does not run OpenAI's built-in web search and without it answers 400 with this very hint. multi_agent = false drops the sub-agent tools from every request — about 1,700 tokens each; keep it true only if you use Codex sub-agents.
  4. 4Put the key into the APIMIRA_API_KEY environment variable (third tab): export on macOS and Linux, $env: or setx in PowerShell. The key is created in the dashboard and shown once; do not write it into the config files.
  5. 5Run codex --profile apimira. Agentic mode works: reading and editing files, terminal commands, multi-turn conversations, streaming output. Without --profile Codex keeps using your previous provider.
[model_providers.apimira]
name = "ApiMira"
base_url = "https://apimira.com/v1"
env_key = "APIMIRA_API_KEY"
wire_api = "responses"

The recommended model is openai/gpt-5.3-codex: Codex prompts and tools are tuned for GPT models, and this one has a cached-input rate in the catalog — Codex sends the whole history with every request, and the repeated beginning is billed at the discounted rate. Models from other families with tool calling work too — anthropic/claude-sonnet-4.6, for instance. Codex keeps the conversation history itself (store = false, the full input every turn), so the gateway rejects previous_response_id with code unsupported_parameter, and responses cannot be fetched or deleted by id — 404. OpenAI's built-in tools (web_search, file_search, code_interpreter, tool_search, custom) are not executed by the gateway and answer 400 with the type name; functions executed by Codex itself work in full. The reasoning, include, prompt_cache_key, metadata, parallel_tool_calls, store and text.verbosity fields are accepted and never reach the model — they are OpenAI telemetry and hints; text.format other than text, as well as input_file, answer 400 unsupported_parameter. Images work: an input_image part with a data:image/png;base64,… URL (PNG, JPEG or WebP, up to 5 MB each, up to 50 per request) reaches the model, including an image returned by a tool — the gateway passes it to the model as a separate user turn. A detail of original is treated as high; remote URLs are not fetched, and a model without the "Sees images" mark answers with unsupported_capability. The warning "Model metadata for … not found. Defaulting to fallback metadata" at the start of every session is normal: Codex does not know our IDs and falls back to default settings. Output ceiling: Codex does not set max_output_tokens, so every request reserves the input plus 32,000 output tokens — or as much as the remaining balance covers (about $0.09 per request for gpt-5.3-codex). Below that balance a long answer is cut by balance (response.incomplete), Codex retries the turn up to five times and hits 402 — keep a few such reserves on the balance. Reserves add up only with parallel sub-agents (multi_agent = true). On Windows, non-interactive codex exec without a configured sandbox blocks file writes, and sandbox = "elevated" in the [windows] section of config.toml (the value the Codex desktop app sets) needs a UAC prompt, so in a session without a screen it fails while launching the helper; for codex exec set sandbox = "unelevated" and run with --sandbox workspace-write. In interactive codex this is handled by action approvals. Editing files with Cyrillic text through apply_patch in PowerShell may go into retries — the turn gets more expensive.

Function calling is supported, so agentic modes work. Strict JSON mode (response_format) and the retired functions format are rejected with an unsupported_parameter error — the parameter is never silently dropped. Image input is accepted by models marked "Sees images" on the Models page: a content part of type image_url with a data:image/png;base64,… URL (PNG, JPEG or WebP, up to 5 MB each, up to 50 per request). Remote URLs are not fetched, and a model without that mark answers with unsupported_capability — both errors name the reason outright.