Fix "prompt_cache_retention is not supported on this model " Gateway 400 Errors
Fix the "prompt_cache_retention is not supported on this model" HTTP 400 error and the reasoning_effort function tools loop across Codex, OpenAI-compatible gateways.
Summary
- The top-level prompt_cache_retention parameter (usually sent as "24h") is rejected by GPT-5.6, GPT-6, GPT-6.1, and strict OpenAI-compatible upstreams.
- Setting prompt_cache_retention to null or false in gateway overrides does not remove the key; you must strip it at the exit sanitizer.
- If your local request body does not contain the parameter at all.
- When calling GPT-5.4 through GPT-6.1 with tools, do not set reasoning_effort to "none" on /v1/chat/completions.
If your coding agent or API gateway suddenly starts failing with HTTP 400 and returns "prompt_cache_retention is not supported on this model", the request payload reaching the model worker contains a deprecated top-level caching field:
{
"error": {
"message": "prompt_cache_retention is not supported on this model",
"type": "invalid_request_error",
"param": "prompt_cache_retention",
"code": "invalid_parameter"
}
}
I ran into this across gpt-5.6-sol, gpt-5.6-luna, gpt-5.6-terra, and the newer GPT-6 Astra, Sol, and Luna models. The legacy prompt_cache_retention parameter—most often sent with a value of "24h"—is rejected by these models. Under OpenAI's current Prompt Caching specification, cache lifetime on the Responses API is configured through the nested prompt_cache_options.ttl field, where "30m" is currently the only supported value. Non-OpenAI upstreams with strict Pydantic validation, such as GLM 5.2, also reject the legacy field with Extra inputs are not permitted, field: 'prompt_cache_retention', value: '24h'.
What makes this error frustrating to debug is that when you check ~/.codex/config.toml or your client's outgoing parameters, prompt_cache_retention is rarely there. Depending on your stack, the parameter is being attached in one of three places: a hidden client toggle or sub-agent builder, an API gateway transform, or OpenAI's own consumer Codex routing layer.
On this page
1. Client "Cache-Friendly" Toggles and Sub-Agent Overrides
Many desktop clients and coding agents attach "prompt_cache_retention": "24h" automatically whenever long-cache optimization is enabled, without exposing the raw key name in their settings file.
If you are routing through an opencode panel or a similar wrapper and hit a 400 on GLM 5.2 or gpt-5.6-sol, turn off the "Enable cache-friendly mode" (启用缓存友好化) toggle in the provider panel. That single switch is what injects "prompt_cache_retention": "24h" into every outgoing request.
In Kilo Code (such as v7.4.22), this bug shows up only when delegating work. Your parent session runs fine on gpt-5.6-luna or gpt-5.6-sol, but the moment it spawns a Task or sub-agent with xhigh reasoning, the child task dies before processing with APIError: prompt_cache_retention is not supported on this model (Retryable: false). Even resuming with the returned task_id triggers the same 400 because Kilo attaches the legacy parameter specifically on sub-agent requests at high reasoning tiers. Turning off prompt caching in Kilo's settings, switching the sub-agent off Luna/Sol, or dropping the sub-agent reasoning effort down to low or medium bypasses that parameter injection path.
Why Client Auto-Recovery Fails on Custom Gateways
Some clients (like Cindy v0.1.112 in long-cache mode) intentionally send "prompt_cache_retention": "24h" on the first turn and rely on an error matcher to strip the field if the upstream complains. That fallback breaks as soon as you use a custom OpenAI-compatible gateway that translates or reformats upstream error payloads.
When the gateway returns a localized message such as 未知请求字段:prompt_cache_retention (code: UNKNOWN_FIELD, data.field: prompt_cache_retention) on /v1/chat/completions, or 当前模型或上游不支持 Responses 能力:prompt_cache_retention (code: RESPONSES_FEATURE_NOT_SUPPORTED, param: null) on /v1/responses, the client's recovery logic fails because it looks strictly for the English string "prompt_cache_retention is not supported" and expects param to equal "prompt_cache_retention". Because neither matches, the client never records that the channel rejects the field, and every subsequent turn fails immediately. You have to disable long-cache mode in the client or strip the field at the gateway before it reaches the upstream provider.
2. Gateway Passthrough and Why null Overrides Do Not Work
If you run a local or self-hosted proxy between your coding client and the upstream API, the proxy itself is often the culprit.
In CLIProxyAPI (CPA) v7.2.136, the request sanitizer strips prompt_cache_options and prompt_cache_breakpoint before forwarding requests to models like gpt-5.6-terra, but leaves prompt_cache_retention untouched. When a client like ZCode includes the field, CPA passes it straight through and triggers the 400. Upgrading CLIProxyAPI to v7.2.137 or later adds prompt_cache_retention to the filter list.
If you are using New API, Sub2API, or a local models.json override in Pi, avoid these two common dead ends:
- Setting
"prompt_cache_retention": nullorfalsein channel overrides: Upstream schema validators still parse the key name and rejectnullor boolean values on models where the parameter is unsupported. - Relying on a top-level
deleterule when internal bridges run later: In gateways like Sub2API (v0.1.173 through v0.1.178), the standard/v1/responsespath andapplyCodexOAuthTransformstripprompt_cache_retentionfrom the top-level JSON, yet requests togpt-5.6-luna,gpt-5.6-sol,gpt-5.6-terra, andgpt-5.5still intermittently fail with the exact same 400—especially when hitting internal routes like the Codex image-generation bridge. If a downstream transform or nested payload branch re-attaches default cache fields after your initialdeleterule executes, the upstream will still reject the turn.
To verify whether your gateway is actually sending a clean payload, point your client's base_url at a local echo listener (see how I test raw payloads in our OpenAI Python SDK base_url guide) and inspect the final JSON leaving the exit adapter.
3. Server-Side Injection on chatgpt.com/backend-api/codex
What if you capture the exact HTTP request leaving your machine, confirm that prompt_cache_retention is completely absent from the JSON body, and still get prompt_cache_retention is not supported on this model?
This happens when calling https://chatgpt.com/backend-api/codex/responses (via OpenAI OAuth or ChatGPT subscription backends in Codex Desktop, Codex CLI 0.147.0 / 0.148.0, or Hermes Agent). Even if you send a minimal request containing only model, instructions, input, store, and stream (plus prompt_cache_key), about 1 in 5 requests will fail with HTTP 400 prompt_cache_retention is not supported on this model.
In this scenario, your client is not sending the parameter. An internal routing node on OpenAI's consumer Codex backend is injecting the legacy parameter server-side before forwarding the request to the model worker.
Because the fault is in upstream server-side routing, two popular workarounds do not hold up in practice: downgrading @openai/codex from 0.148.0 to 0.147.0 still hits the error intermittently, and switching the model from gpt-5.6-sol to gpt-5.5 fails on the same routing nodes.
Instead, use the fix that matches how you run Codex:
- Bypass the Codex Desktop
app-serveron macOS: When Codex Desktop (such as build 6720 / CLI0.148.0-alpha.15) hits this 400, the UI masks the parameter error as"Reconnecting 1/5"and retries the identical bad request five times, making it look like a network outage or a hung tool call. If you run the bundled binary directly from your terminal via/Applications/ChatGPT.app/Contents/Resources/codexwith the exact same model and local~/.codex/config.toml, it bypassesapp-serverand completes tool calls and web searches normally. - Treat this specific HTTP 400 as retryable in agent frameworks: Frameworks like Hermes Agent (v0.20.4 and earlier) classify any HTTP 400 as a
Non-retryable client errorand immediately abort the turn. Because server-side injection on the consumer Codex endpoint fails on roughly 20% of requests while succeeding on the next attempt seconds later, configure your exit adapter to both stripprompt_cache_retentionon egress and automatically retry when a 400 response containsparam: "prompt_cache_retention".
4. Fixing the Next Gateway Trap: Function tools with reasoning_effort are not supported
Once you clear the prompt_cache_retention error and start running tool-enabled workflows through an OpenAI-compatible gateway on gpt-5.4, gpt-5.5, gpt-5.6-luna, gpt-6-astra, or gpt-6.1-sol, you will frequently hit a second HTTP 400 parameter error:
Function tools with reasoning_effort are not supported for gpt-5.6-luna in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'.
If you are using gpt-6.1-sol (or gpt-6-astra), do not follow the second half of that error message.
When you set reasoning_effort to "none" on gpt-6.1-sol in Open WebUI, Cherry Studio, or Cline, the upstream API immediately rejects the request with a contradictory 400 error:
Unsupported value: 'reasoning_effort' does not support 'none' with this model. Supported values are: 'low', 'medium', 'high', and 'xhigh'.
Setting it back to low, medium, high, or xhigh throws the first error again, locking you in a loop on /v1/chat/completions. (If you hit other 400 messages in coding terminals, I keep a separate breakdown in Claude Code API Error 400: How Do I Fix Each Message?.)
To use function calling on GPT-5.4 through GPT-6.1 without getting trapped between those two errors, you have three working options:
Switch the Client Protocol to /v1/responses
OpenAI restricts simultaneous tools and reasoning_effort on /v1/chat/completions, but allows both together on /v1/responses.
In Cline CLI, open ~/.cline/data/settings/models.json and set "protocol": "openai-responses" on your custom provider entry so requests route to /v1/responses. In Codex CLI, set wire_api = "responses" in your configuration.
Verify Your Gateway Actually Exposes /v1/responses
If you switch your client to /v1/responses and suddenly get Resource not found (404)—or if you still get the exact same /v1/chat/completions error message despite configuring wire_api = "responses"—your intermediate gateway is the bottleneck. Older LiteLLM instances and several New API hub stations either do not expose /v1/responses at all, or accept incoming /v1/responses requests and translate them back into /v1/chat/completions calls upstream. You must enable native /v1/responses passthrough on the gateway (for example, forcing the Responses API route in Sub2API) or upgrade LiteLLM.
Omit reasoning_effort Completely (Instead of Passing "none")
If your client or middleware is locked to /v1/chat/completions and cannot use /v1/responses, do not pass "reasoning_effort": "none". Remove the reasoning_effort key from the JSON request body entirely, or route your tool-calling turns to a non-reasoning model such as gpt-5.4-mini.
If you are tired of patching local proxy sanitizers every time an upstream model deprecates a cache key or rejects /v1/chat/completions tool parameters, I route my own multi-model workloads through SeedRouter. It handles native /v1/responses routing and strips incompatible legacy fields before they can trigger an upstream 400.