跪拜 Guibai
← All articles
Backend · Programmer · Artificial Intelligence

Codex's 1M Context Window Is a Billing Trap, Not a Free Upgrade

By cxuanAI ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A 1M context window sounds like a productivity unlock, but the 272k billing cliff means every large request costs at least double. Developers who turn this on without understanding the pricing model, or who run it through a proxy that lacks overage billing, will see sudden, steep charges.

Summary

Setting the 1M context window in Codex requires either a one-time CLI flag or a permanent entry in ~/.codex/config.toml. Both methods are straightforward, but the OpenCodex proxy tool overrides them. OpenCodex hardcodes a 372k context window in its source and injects its own config on every launch via a shim, so user edits to the TOML file disappear after each session. Stopping the proxy process is not enough; the auto-start mechanism must be disabled with `ocx system settings --auto-start off` before the native 1M setting sticks.

Even after the local config works, the server-side billing model undercuts the benefit. OpenAI treats any request exceeding 272k tokens as a premium tier: the entire input price doubles and the output price rises 1.5x. The 272k cap was originally a deliberate guardrail to prevent surprise charges, and the new 1M availability does not remove that pricing cliff. Subscribers now have access to the larger window, but overage billing remains separate and is not advertised alongside the feature announcement.

API proxy operators face the sharpest risk. If a proxy does not explicitly enable the separate billing switch for over-272k usage, a single user's 1M-context session can generate costs that the proxy owner absorbs directly.

Takeaways
Codex accepts a 1M context window via the `model_context_window=1000000` and `model_auto_compact_token_limit=900000` config options, either as CLI flags or in ~/.codex/config.toml.
OpenCodex hardcodes a 372k context window in its source and overwrites user config on every launch through a shim that calls `ocx ensure`.
Stopping the OpenCodex proxy with `ocx stop` is insufficient; the auto-start mechanism must be disabled with `ocx system settings --auto-start off` to prevent config re-injection.
OpenAI's billing model doubles the input price and applies a 1.5x output multiplier for any request exceeding 272k tokens, a guardrail that predates the 1M window announcement.
Subscribers can now request a 1M context window, but the over-272k surcharge remains separate and is not mentioned in the feature announcement.
API proxy operators who have not enabled the separate overage billing switch will personally absorb the multiplied costs of any user's 1M-context session.
Conclusions

The 272k billing cliff was originally a protective measure, but its survival into the 1M era turns a safety rail into a hidden cost that the official announcement omits.

OpenCodex's hardcoded context window and auto-start shim create a silent config-revert bug that looks like a Codex issue but is entirely a third-party wrapper problem.

The gap between local config success and server-side billing reality means a developer can appear to have 1M working while unknowingly triggering premium pricing on every request.

Concepts & terms
Context window
The maximum number of tokens a language model can process in a single request, including both input and output. A larger window allows the model to consider more code, conversation history, or documentation at once.
Auto-compaction token limit
A threshold in Codex that triggers automatic context compression when the conversation approaches the configured token count, intended to keep the session within the model's effective window.
Codex shim
A wrapper process used by OpenCodex that intercepts calls to the `codex` CLI, injecting its own proxy configuration and restarting the proxy process on every invocation.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗