Skip to content

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.

Error output
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.

  1. 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.

  2. 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.

  3. On Google AI Studio / Gemini, make sure `base_url` is filled in correctly, or forward through OpenRouter to sidestep the format compatibility problem.

ToolClaude Code
VersionUnknown
PlatformsWindowsmacOSLinux
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.

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.