feat(provider): add Google Vertex/AI context caching annotations#17569
Open
ccompton-merge wants to merge 2 commits intoanomalyco:devfrom
Open
feat(provider): add Google Vertex/AI context caching annotations#17569ccompton-merge wants to merge 2 commits intoanomalyco:devfrom
ccompton-merge wants to merge 2 commits intoanomalyco:devfrom
Conversation
Add cache point annotations for Google providers (@ai-sdk/google-vertex and @ai-sdk/google) in the applyCaching() and message() functions. Currently, applyCaching() sets cache control hints for Anthropic, OpenRouter, Bedrock, Copilot, and OpenAI-compatible providers, but skips Google/Vertex entirely. This means Gemini models miss out on the AI SDK's cache point signaling, which can significantly improve implicit context caching hit rates. Changes: - Add google.cachePoint annotation to applyCaching() provider options - Extend message() to call applyCaching() for @ai-sdk/google-vertex and @ai-sdk/google models (previously only called for Anthropic)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #6851
Related: #17568
Type of change
What does this PR do?
Implements part 1 (Provider Transformation) of #6851.
applyCaching()intransform.tssets cache hints for several providers but skips Google. This adds thecachePointannotation for@ai-sdk/google-vertexand@ai-sdk/google, matching the pattern already used by thebedrockentry.Two changes (5 lines total):
google: { cachePoint: { type: "default" } }toapplyCaching()provider optionselse ifinmessage()to callapplyCaching()for Google provider modelsFully backward-compatible —
cachePointis a hint the AI SDK passes to the Google provider; providers that don't support it ignore it. Parts 2-3 from #6851 (usage tracking, LLM orchestration) can follow separately.Thanks for building OpenCode. 🙏
How did you verify your code works?
transform.tscachePointannotation follows the same pattern as the existingbedrockentrymessage()condition follows the same guard-clause pattern as the Anthropic branch@ai-sdk/google-vertexand@ai-sdk/googlesupportcachePointScreenshots / recordings
N/A — no UI changes.
Checklist