Skip to content

Improve prompt caching for Gemini models on OpenRouter #36069

Closed as not planned
Closed as not planned

Description

@AbdoKnbGit

Description

When using Gemini models through OpenRouter, prompt cache reads are low and inconsistent in longer sessions.

OpenCode already adds cache breakpoints for Claude models, but not for Gemini models routed through OpenRouter. OpenRouter supports explicit cache_control breakpoints for Gemini and recommends using a stable session_id for routing.

Could OpenCode enable the existing cache-control behavior for OpenRouter Gemini models and send the OpenCode session ID as session_id?

I tested this locally and it improved cache reuse, although partial reads are still expected because of Gemini's caching limitations.

Activity

  1. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or closely related to an existing issue. Please check:

    • [FEATURE]: Set prompt_cache_ttl for OpenRouter provider #16848: Also covers cache_control breakpoints for the OpenRouter provider, including the documented mechanism for prompt caching (cache_control: { type: "ephemeral" } on message content). The Gemini-specific session_id routing angle in this issue may be a distinct addition, but the underlying caching infrastructure discussion overlaps significantly.
  2. github-actions commented on Sep 8, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions