June 8, 20263 min readModelsGPT-5.2 Codex

GPT-5.2 Codex API - pricing, context window and best use cases

GPT-5.2 Codex is OpenAI's coding-specialized variant of the GPT-5.2 family, tuned for agentic software work: reading a repository, planning a change, editing multiple files, and running tools in a loop. If you write code for a living, the questions that actually matter are practical ones - what does it cost per token, how much context can you realistically feed it, and where does it earn its keep versus a general-purpose model. This guide answers those without the hype.

How pricing works

Codex-class models are billed per token, split into input (your prompt, including the whole repo context you attach) and output (the code and explanations it generates). Output tokens are the more expensive side, and on agentic runs they add up fast because the model often writes, re-reads, and revises.

Two cost levers matter more than the headline rate:

  • Prompt caching. Re-sending the same system prompt and file context across turns is dramatically cheaper when cached. Long agent sessions benefit the most.
  • Reasoning effort. Codex models expose effort levels. Higher effort burns more output tokens on internal reasoning before answering - great for a gnarly bug, wasteful for a rename.

Because published per-token rates shift over time, always confirm the current number before you budget. On AnyModel you pay per token with no subscription and no minimums, so a quiet week simply costs less. You can sanity-check relative costs across models on the compare page before committing a workload to any one of them.

Context window, and what it actually buys you

GPT-5.2 Codex ships with a large context window - big enough to hold a substantial slice of a codebase plus conversation history in a single request. But a large window is a budget, not a free lunch:

  • Every token in context is billed as input on each turn.
  • Models attend less reliably to the middle of very long contexts than to the start and end.
  • Pasting an entire monorepo is usually worse than pasting the five files that matter.

The win from a big window is fewer round trips - you can include the failing test, the implementation, and the relevant types together so the model reasons over the whole picture at once. Treat the window as room for relevant context, not a dumping ground.

Best use cases

Where GPT-5.2 Codex tends to shine:

  • Multi-file refactors - propagating a signature change or extracting a module across a package.
  • Test-driven fixes - hand it a red test and the code; it iterates to green.
  • Code review and migrations - upgrading a framework version or flagging risky diffs.
  • Agentic CLI work - inside Codex CLI, where it can run commands, read output, and self-correct.

Where a cheaper or general model is often the better call: quick one-liners, doc writing, and casual Q&A. That flexibility is the point of a gateway - browse what is available on the models page and switch per task instead of locking into one.

Using it through AnyModel

AnyModel is one OpenAI-compatible endpoint. The base URL is https://anymodel.org/v1, and a single API key reaches GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok. Switching models means changing the model id - nothing else in your code moves.

For Codex CLI, the one-line install wires everything up:

bash <(curl -fsSL "https://anymodel.org/i?tool=codex") <YOUR_API_KEY>

The same installer supports claude, opencode, and hermes. For Cursor, Windsurf, Zed, Cline, Aider, Continue, or Gemini CLI, point the tool's OpenAI-compatible settings at the base URL above with your key.

If you handle proprietary code, enable Ghost Mode - opt-in, zero-retention keys where prompts and responses are not stored on our side, only a token counter. Note the honest caveat: the model provider still receives your prompt, so this is not a blanket privacy guarantee.

Getting started

You can try GPT-5.2 Codex with 1,000,000 free tokens on signup - no credit card - and a total of 6,000,000 if you link Telegram. After that it is straight pay-per-token. For more model deep-dives, the blog has comparisons and walkthroughs.

Ready to ship faster? Create your free account and point Codex at AnyModel in under a minute.

Read next