Skip to content

Improve prompt caching for Gemini models on OpenRouter #36069

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions