Issue #19185, around 23 April 2026, set Codex config.toml model_context_window to 960000 for gpt-5.5. Codex still used about 258k.

The user file is ~/.codex/config.toml. A trusted project uses .codex/config.toml. CODEX_HOME must already be a directory, and the file is then $CODEX_HOME/config.toml.

Highest first: CLI flags, trusted project file, profile, user file, cloud defaults, system file, built-in defaults. Copy the starting file below.

Guides still tell you to set wire_api = "chat" and model_context_window. Codex errors on the first and clamps the second.

Checked: source on 25 Aug 2026 (rust-v0.150.0-alpha.8), docs on 28 to 29 Oct. I haven't reproduced either key myself.

Where does Codex config.toml live?

The public pages write the user path as ~/.codex/config.toml. The per-OS paths below are what find_codex_home resolves.

OSUser config, when CODEX_HOME is unset
macOS$HOME/.codex/config.toml
Linux$HOME/.codex/config.toml
Windows%USERPROFILE%.codex\config.toml

Codex resolves the directory in find_codex_home (codex-rs/utils/home-dir/src/lib.rs, commit 9a8730f3, retrieved 28 October 2026). A set CODEX_HOME must already exist and be a directory, and Codex canonicalises it. When it's unset, dirs::home_dir() plus .codex is $HOME on macOS and Linux, and the Windows profile folder (FOLDERID_Profile, what %USERPROFILE% points at) on Windows. Codex runs on built-in defaults until you create the file.

In the IDE extension: gear icon, Codex Settings, Open config.toml. Same file as the CLI, on Config basics.

A repo can add .codex/config.toml. Codex reads it only after you trust the project. It walks from the project root down to your working directory and loads every .codex/config.toml it finds. When two of them set the same key, the one closest to the working directory wins.

A profile is a separate file, ~/.codex/<name>.config.toml (or $CODEX_HOME/<name>.config.toml), selected with --profile <name>. The public docs name one system path, /etc/codex/config.toml on Unix. The loader also reads %ProgramData%\OpenAI\Codex\config.toml on Windows (codex-rs/config/src/loader/mod.rs, commit 178c3d30, retrieved 28 October 2026).

Precedence, highest first, on Config basics:

  1. CLI flags and --config overrides
  2. Trusted project .codex/config.toml files, closest to the working directory first
  3. The profile selected with --profile
  4. ~/.codex/config.toml
  5. Cloud-managed config.toml defaults for the signed-in workspace
  6. /etc/codex/config.toml on Unix, when that file is present
  7. Built-in defaults

An earlier version of this post said that order was undocumented. The 25 August source pass pointed at codex-rs/config/src/overrides.rs, and the docs page lists the order now.

A project .codex/config.toml can't set provider, notification, profile, or telemetry keys. Codex ignores these keys there and prints a startup warning. Put them in the user file. The configuration reference names them:

  • openai_base_url
  • chatgpt_base_url
  • apps_mcp_product_sku
  • model_provider
  • model_providers
  • notify
  • profile
  • profiles
  • experimental_realtime_ws_base_url
  • otel

What a minimal Codex config.toml looks like

This is OpenAI's sample config cut to five keys (checked 29 Oct). Fill in the model yourself.

# pick a model your account can use
# Primary model Codex runs. The sample configuration sets a model id on this key.
# model = "..."
 
# When Codex asks before a command. on-request: the model decides. Default: on-request.
approval_policy = "on-request"
 
# Filesystem and network policy for tool calls. Default: read-only.
sandbox_mode = "read-only"
 
# Web search mode. cached serves the web search cache. Default: cached.
web_search = "cached"
 
# Reasoning effort for the selected model. The sample leaves this unset and shows medium.
# Supported levels vary by model. No separate default is named on that line.
# model_reasoning_effort = "medium"

Providers, MCP servers, and the rest of the file are on the sample configuration page.

Which config.toml keys matter, and what are their defaults?

These are the keys in the sample and the reference.

KeyDefaultNote
modelYou pick oneThe sample sets an id. Use one your account can run.
approval_policyon-requestSample calls this the default. The model decides when to ask.
sandbox_moderead-onlySample default. The basics page example is workspace-write.
web_searchcachedAlso indexed, live, disabled. Full access uses live.
model_reasoning_effortUnset in the sampleSample shows medium, commented out. Levels vary by model.
model_provideropenaiId selected from [model_providers].
model_context_windowAuto for the modelSample default. A large value is clamped, below.
model_auto_compact_token_limitModel defaults when unsetSample note. Pair it with model_context_window.
wire_apiresponsesOnly value. Under the provider block. Default when omitted.
request_max_retries4Provider field. HTTP retries.
stream_max_retries5Provider field. Streaming retries.
stream_idle_timeout_ms300000Provider field. 5 minutes on the sample page.
supports_standalone_web_searchfalseOff. Standalone search is still under development.

The other keys people change often are log_dir, [shell_environment_policy], and the built-in permission profiles :read-only, :workspace, and :danger-full-access. Under [features], features.multi_agent is stable and on by default, and features.memories is experimental and off by default. Omit a feature key to keep its default.

Config basics tells you to migrate off approval_policy = "untrusted". The configuration reference calls that value unsupported, and still lists untrusted inside allowed_approval_policies for the stricter policy an untrusted project derives. trust_level = "untrusted" in the user file skips project .codex/ layers.

Basics uses personality = "none" to drop the built-in personality instructions. friendly and pragmatic no longer select a style, and /personality is gone. The configuration reference still types the key as none | friendly | pragmatic.

Which keys does Codex accept and then ignore?

The wire_api error is in the source. The clamp comes from issue reports.

Codex takes both of these keys. wire_api = "chat" errors at startup. model_context_window is accepted and then reduced, with no warning.

wire_api = "chat" is a hard error

The wire protocol conversation is openai/codex discussion #7782, opened by etraut-openai (Maintainer) on 9 December 2025. From the opening post:

As a result, the Codex team is deprecating support for the chat/completions API. Full removal is slated for early February 2026.

The Codex CLI will be updated to emit a deprecation warning if configured to use the chat/completions API. In February 2026, this will transition to a hard error as support is fully removed.

Removal landed. bfroemel, in-thread on 5 February 2026: "and it's gone :/" linking PR #10157. A maintainer had confirmed in mid-January that the removal was scheduled for 1 February and that chat was live until then.

The current tree carries removal constants, not deprecation strings. From codex-rs/model-provider-info/src/lib.rs on main:

CHAT_WIRE_API_REMOVED_ERROR:
  `wire_api = "chat"` is no longer supported.
  How to fix: set `wire_api = "responses"` in your provider config.
  More info: https://github.com/openai/codex/discussions/7782
 
OLLAMA_CHAT_PROVIDER_REMOVED_ERROR:
  `ollama-chat` is no longer supported.
  How to fix: replace `ollama-chat` with `ollama` in `model_provider`,
  `oss_provider`, or `--local-provider`.
  More info: https://github.com/openai/codex/discussions/7782

The older path codex-rs/core/src/model_provider_info.rs at commit d886a86 still holds CHAT_WIRE_API_DEPRECATION_SUMMARY, the warning from the deprecation window. The fix in the current constant is wire_api = "responses" in the provider block.

Issue #13628, around 5 March 2026, says the public reference still listed wire_api as chat | responses while the JSON schema defaulted to responses. The reporter wrote that this "makes it hard to build an accurate config.toml reference from the official sources."

jemshit, on 24 January 2026 in the same discussion: wire_api goes under [model_providers.x], not under [profiles.x].

model_context_window is accepted and then clamped

model_context_window and model_auto_compact_token_limit are real keys. The sample documents both.

Issue #19185, around 23 April 2026, "config.toml context window settings are not respected." Windows, gpt-5.5:

model_context_window = 960000
model_auto_compact_token_limit = 800000

Codex still uses about 258k. The report's words: "the configured value is silently reduced/ignored." The reporter asked for the value to be honoured, or for a validation error.

A secondary write-up of etraut-openai on issue #19409, rather than the issue itself, says gpt-5.5 supports 400K, not 1M, and defaults input to 258,400 to leave compaction margin.

Issue #14133 is secondary only. Terminal codex exec honours the key, and Desktop GUI threads ignore it.

Issue #19208, around 23 April 2026: 1M worked on GPT-5.4 and disappeared on GPT-5.5, which was marketed at 1M. The report includes personality = "pragmatic".

Issue #16068, around 28 March 2026, codex-cli 0.117.0 and 0.116.0, gpt-5.3-codex, macOS: the key breaks auto-compaction because fill_to_context_window resets the token counter.

Issue #31860: GPT-5.6 Sol catalog-capped at 372K, 353.4K effective, against a 1.05M model spec.

yigitkonur, 15 April 2026, says the two lines give you 1M. trilogyai.substack.com, around 20 August 2026, adds model_catalog_json. That key was unverified against codex-rs on 25 August 2026. The sample lists it as an optional startup-only override.

trilogyai's 2x input and 1.5x output billing past 272K, for the whole request, is secondary. Check the GPT-5.6 Sol model page before you repeat it.

Issue #19185 is the pattern for the second key: the file said 960000 and the running context was about 258k. Use the running figure before you treat the number in the file as the one in use.

What breaks when you point Codex at a non-OpenAI model

The failures below come from community threads, with the version and date on each report. The Ollama rejection is the removal constant. The only wire value is responses.

LM Studio. FVilli, 28 January 2026, LM Studio 0.3.39 and codex-cli 0.92.0. Non-streaming curl to /v1/responses works, Codex streaming fails, and a same-day maintainer reply said it had worked three weeks earlier. LM Studio is the local path in the announcement thread.

LiteLLM. FedorenkoCodes, 29 January 2026, codex 0.92.0, LiteLLM 1.75.8 and 1.80.15 on an Azure gateway. wire_api = "chat" chats and never calls tools, wire_api = "responses" doesn't connect, and enghalim was still asking on 23 April 2026.

vLLM and llama.cpp. montvid, 10 February 2026, vLLM 15.1 and a fresh llama.cpp build both fail Responses. The next day llama.cpp "kind of works" because its server converts Responses into Chat Completions, per its tools/server/README.md.

z.ai / GLM. gaoconggit, January 2026, works on codex 0.80.0 and breaks on later versions, with {"error": {"code": "1214", "message": "Incorrect role information"}} on glm-4.7.

Tool calling. Issue #30523: custom-provider dynamic tools end a turn without a function_call. The open or closed state of that issue wasn't re-checked.

Those five reports are the same failure: Codex is speaking Responses at an endpoint that hasn't implemented it, has implemented it incompletely, or is translating and then leaking on tools.

The 300 second stall. Issue #23807, "codex-cli stalls for exactly 300s between tool result and next model request (stream disconnected)." 300 seconds matches stream_idle_timeout_ms at 300000. That's an inference from the documented default, not from a run.

Ollama. The removal constant rejects ollama-chat and names ollama as the replacement in model_provider, oss_provider, or --local-provider. That provider expects the Responses API, and Ollama's December 2025 note planned the support with no ship date.

opper.ai, a vendor that sells routing, says some Codex tools use OpenAI-specific formats that other upstreams reject, and mentions features.multi_agent = false. The 25 August source pass didn't find that key. Basics listed it as stable and on by default on 27 October 2026. The source wasn't re-checked after that pass.

Which guides still say wire_api = "chat" works?

ofox.ai, 8 June 2026 (ofox.ai/blog/codex-cli-custom-model-providers-byo-setup/), in a FAQ headed "Does Codex CLI still support wire_api = 'chat' in 2026?":

Yes, both 'responses' and 'chat' are accepted.

Four months after removal. The same page tells readers to set wire_api = 'chat' for third-party gateways, and to fix a 404 on /responses by switching to chat. That advice now produces the hard error above. ofox.ai sells a gateway, so the FAQ and the product point the same way.

morphllm.com, 9 June 2026, a vendor page, gets it right one day later: "responses is the only supported value, and it is the default when omitted."

dev.to/rkttu, around 26 May 2026, an independent post, also gets it right and cites the source: the WireApi enum in codex-rs/model-provider-info/src/lib.rs has one variant.

Which keys go in a model provider block?

This list is from codex-rs/model-provider-info/src/lib.rs on main. The removal constants and the WireApi enum were present there on 25 August 2026. The full field list wasn't enumerated field by field.

Top-level fields on a [model_providers.<id>] block: name, base_url, env_key, env_key_instructions, experimental_bearer_token, auth, aws, wire_api, query_params, http_headers, env_http_headers, request_max_retries, stream_max_retries, stream_idle_timeout_ms, websocket_connect_timeout_ms, requires_openai_auth, supports_websockets, supports_standalone_web_search.

Two nested blocks:

  • [model_providers.<id>.auth] with command, args, timeout_ms, refresh_interval_ms.
  • An Amazon Bedrock block, [model_providers.<id>.aws], with profile, region, and a refresh block.

Retry counts, wire_api, and supports_standalone_web_search are in the table above. requires_openai_auth also defaults to false, on the configuration reference.

Azure is the only non-OpenAI target with a full reference block. Advanced config gives base_url, env_key, env_key_instructions, wire_api = "responses", and an api-version query param. Other providers have no worked example on the OpenAI docs.

The repo also carries an Amazon Bedrock block: a Mantle base URL and a client-agent header constant. A lead, not a recipe.

The configuration reference reserves the built-in provider ids openai, ollama, and lmstudio. A custom provider uses a different id.

Limitations of this post

  • model_catalog_json is on the sample page and hasn't been traced into codex-rs.
  • The 2x input and 1.5x output billing claim past 272K tokens is secondary, and unverified against the model page.
  • features.multi_agent = false for third-party backends comes from a vendor blog. The docs later list the key as stable and on by default. The source wasn't re-checked.
  • The open or closed state of issues #30523, #23807, #19409, #16068, and #31860 wasn't re-checked.
  • This post has no live capture of the wire_api = "chat" error text, and no live capture of the number model_context_window clamps to.
  • Approval, sandbox, profile, and MCP keys are covered only as far as the docs pages quoted above.

Frequently asked questions

Where is Codex CLI config.toml?
The user file is ~/.codex/config.toml: $HOME/.codex/config.toml on macOS and Linux, and %USERPROFILE%\.codex\config.toml on Windows. A trusted project adds .codex/config.toml, and CODEX_HOME, pointed at a directory that already exists, moves the file to $CODEX_HOME/config.toml.
Does Codex CLI still support wire_api = 'chat' in 2026?
No. Discussion #7782 deprecated it on 9 December 2025, PR #10157 removed it in early February 2026, and the source now hard-errors unless wire_api is responses, the default when the key is omitted.
How do I point Codex CLI at Ollama?
Use the ollama provider. ollama-chat was removed with wire_api = chat and now hard-errors with a pointer at discussion #7782, and the remaining provider expects Ollama to speak the Responses API, which the December 2025 maintainer note planned without a ship date.
Why is my model_context_window setting ignored?
Codex accepts the number and then clamps it. Issue #19185 set 960000 for gpt-5.5 and still saw about 258k, and a secondary note of etraut-openai on issue #19409 puts the gpt-5.5 input default at 258,400.
Can I use Codex CLI with Claude, Gemini, or other non-OpenAI models?
Only through something that speaks the Responses API, because the WireApi enum has one variant. LiteLLM, llama.cpp's server shim, and Azure are the reported paths, and Azure is the non-OpenAI target the advanced config page writes out.
Where does wire_api belong in config.toml?
Under [model_providers.<id>], not under a profile. jemshit said so on 24 January 2026 in discussion #7782: a profile can name a provider by id, and the wire protocol is a field on the provider.
What is the precedence between env vars, config.toml, profiles, and CLI flags?
Highest first: CLI flags and --config, trusted project files closest to the working directory, the --profile file, the user file, cloud defaults, the system file, then built-in defaults. env_key is read from the provider block when that provider runs, and a project file can't set provider keys.
What is the default Codex config.toml?
Codex runs on built-in defaults until the file exists. The sample uses approval_policy on-request, sandbox_mode read-only, and web_search cached, and you choose the model.
How do I set a model, sandbox and approval policy in config.toml?
Put the three keys in ~/.codex/config.toml, or in $CODEX_HOME/config.toml when CODEX_HOME is set. The sample uses on-request for approval and read-only for the sandbox, and the model has to be one your account can use.