mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4742] [Issue]: Google models do not cache prompt when using Openrouter as provider #2604
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2604
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @firelightning13 on GitHub (Aug 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4742
Originally assigned to: @SpicyMarinara on GitHub.
Summary
When
enableCachingis toggled on for an OpenRouter connection, Marinara only sends thecache_controlflag for Claude models. Models that support OpenRouter prompt caching — such as Google Gemini — never receive the flag, resulting in full-price token costs instead of cached pricing.Expected behavior
When "Enable Prompt Caching" is toggled on for an OpenRouter connection, Marinara should send
cache_control: { type: "ephemeral" }for all models, so that any model supporting OpenRouter prompt caching (Claude, Gemini, etc.) receives the benefit. OpenRouter gracefully ignores the flag for models that don't support caching.Actual behavior
The
shouldUseOpenRouterPromptCachingmethod inpackages/server/src/services/llm/providers/openai.provider.ts(line ~930) gates thecache_controlflag behind a model-name check:Because of the
options.model.toLowerCase().includes("claude")condition, non-Claude models that support caching on OpenRouter (e.g., Google Gemini) never receive thecache_controlflag, even when the user has explicitly enabled prompt caching in the connection settings.Some models (DeepSeek, GLM, MiMo) cache automatically on OpenRouter's side without needing the flag, so they appear to work fine. Google Gemini requires the explicit
cache_controlflag per OpenRouter's docs, so it silently gets no caching.Steps to reproduce
google/gemini-3.6-flashorgoogle/gemini-3.1-pro-preview).Environment
Logs, screenshots, or video
After removing the
options.model.toLowerCase().includes("claude")gate fromshouldUseOpenRouterPromptCaching, Google Gemini Flash via OpenRouter started receiving cached tokens, resulting in approximately a 50% cost reduction on subsequent messages in the same chat.Additional context
cache_controlflag: https://openrouter.ai/docs/guides/best-practices/prompt-caching#how-to-enable-gemini-prompt-cachingoptions.model.toLowerCase().includes("claude")condition fromshouldUseOpenRouterPromptCaching, so the flag is sent for all OpenRouter models whenenableCachingis true. OpenRouter ignores the flag for models that don't support caching, so this is safe.Or add the Gemini model under Claude's option, though this assumes only two provider supports:
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Aug 8, 2026):
Claimed by @SpicyMarinara for the current assigned-issue sweep. Implementation and validation are tracked in draft PR #4747.