Skip to content

fix: exclude prompt_cache_key for Gemini API requests#790

Merged
alexhoshina merged 1 commit intosipeed:mainfrom
rordd:fix/gemini-prompt-cache-key
Feb 26, 2026
Merged

fix: exclude prompt_cache_key for Gemini API requests#790
alexhoshina merged 1 commit intosipeed:mainfrom
rordd:fix/gemini-prompt-cache-key

Conversation

@rordd
Copy link

@rordd rordd commented Feb 25, 2026

Problem

Gemini's OpenAI-compatible endpoint (generativelanguage.googleapis.com) rejects unknown fields in the request body. The prompt_cache_key field (added in #617) causes a 400 error:

Invalid JSON payload received. Unknown name "prompt_cache_key": Cannot find field.

Solution

Only include prompt_cache_key in the request body for OpenAI-native endpoints. Skip it when the API base URL contains generativelanguage.googleapis.com.

Testing

  • Verified Gemini 2.5 Flash no longer returns 400 errors
  • OpenAI endpoints continue to receive prompt_cache_key as before

Gemini's OpenAI-compat endpoint rejects unknown fields.
Only send prompt_cache_key to OpenAI-native endpoints.
Copy link
Collaborator

@alexhoshina alexhoshina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexhoshina alexhoshina merged commit 95b246f into sipeed:main Feb 26, 2026
2 checks passed
@Orgmar
Copy link
Contributor

Orgmar commented Feb 27, 2026

@rordd That Gemini compatibility fix is solid. The prompt_cache_key field silently breaking requests on generativelanguage.googleapis.com is the kind of edge case that's easy to overlook when adding OpenAI-specific features. Clean conditional approach.

We have a PicoClaw Dev Group on Discord where contributors share ideas and collaborate. If you're interested, send an email to support@sipeed.com with the subject [Join PicoClaw Dev Group] rordd and we'll get you the invite link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants