Unknown name "prompt_cache_key" - cc-switch
Quick fix
Upgrade cc-switch to v3.16.2+ to fix prompt_cache_key injection, or use an OpenRouter endpoint that natively speaks the Claude Code format.
Symptom
Section titled “Symptom”API Error: 400 [{"error":{"code":400,"details":[{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"description":"Invalid JSON payload received. Unknown name \"prompt_cache_key\": Cannot find field."}]}],"message":"Invalid JSON payload received. Unknown name \"prompt_cache_key\": Cannot find field.","status":"INVALID_ARGUMENT"}}]When converting a Claude request into OpenAI format, cc-switch injects a `prompt_cache_key` field into the request body. Some upstream gateways — Google AI Studio among them — do not support that field and return a 400. The cluster also mixes in other variants: a "region error" with OpenRouter caused by IP restrictions or the Claude Code initialisation mechanism, and a config error triggered by leaving `base_url` empty when configuring Gemini.
Upgrade cc-switch to v3.16.2 or newer, which reworked the fallback and injection logic for `prompt_cache_key` in the adapter, resolving both cache bleed and incompatibility.
OpenRouter users: prefer their endpoint that natively supports the Claude Code format, with no local proxy needed. On a region error, configure the API key and request address once through terminal environment variables and get a successful run first, then switch through cc-switch.
On Google AI Studio / Gemini, make sure `base_url` is filled in correctly, or forward through OpenRouter to sidestep the format compatibility problem.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 6 real issues
- #425使用openRouter发现proxy没有生效?
- #1159代理gemini,供应商为OpenRouter,都是默认配置,失败
- #1340使用google ai studio的openai的接口配置到ccs中,使用claudecode 无响应输出(已经使用代理服务模式)
- #1574代理问题请教
- #3193[Bug] Multiple Claude Code sessions share the same prompt_cache_key, causing prompt cache eviction and low hit rates
- #5319Add TokenRouter as a provider preset
- The OpenRouter connection test passes, so why does Claude Code keep reporting a region error?
- OpenRouter may be blocking your IP, or Claude Code may need the key and request address configured once through environment variables and run successfully before it can switch through cc-switch. Prefer the OpenRouter endpoint that natively supports the Claude Code format.
- How do I resolve "Gemini Provider is missing base_url configuration"?
- Fill in the complete `base_url` in the Gemini provider config in cc-switch, or forward Gemini models through OpenRouter instead.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.