Skip to content

docs(config): prompt_cache only caches via the OpenRouter Claude route - #309

Merged
cboettig merged 1 commit into
mainfrom
docs/prompt-cache-openrouter-route
Jul 10, 2026
Merged

docs(config): prompt_cache only caches via the OpenRouter Claude route#309
cboettig merged 1 commit into
mainfrom
docs/prompt-cache-openrouter-route

Conversation

@cboettig

Copy link
Copy Markdown
Member

What

Corrects the prompt_cache documentation added with #302. The flag attaches an Anthropic cache_control breakpoint to the system prompt — but whether it saves anything is decided by the model string, because open-llm-proxy get_provider_for_model() routes by name.

Ground truth (proxy logs, 2026-07-10)

value Route Effect
anthropic/claude-haiku-4.5 OpenRouter → Anthropic ✅ caches — logged cache_write_tokens:6841 (1st call, $0.0086) then cached_tokens:6841 (2nd call, $0.0007), ~12× cheaper on the cached prefix
claude-haiku-4-5 Anthropic-direct OpenAI-compat ❌ no-op — prompt_tokens_details: None; that endpoint ignores message-embedded cache_control (native /v1/messages-only)

The previous note told users to enable it 'on Anthropic-routed models only' — which is exactly the route where the flag does nothing. This rewrite:

  • Adds a routing table and steers Claude entries to the anthropic/… OpenRouter model id + prompt_cache: true.
  • Updates the example config value to anthropic/claude-haiku-4.5.
  • Keeps the per-model rationale (opt-in caching, content-parts reshape), drops the incorrect 'reaches the provider' implication for the bare route.

No code change — docs only.

The prompt_cache flag (#273/#302) attaches a cache_control breakpoint to
the system prompt, but whether that saves anything is decided by the model
string, because open-llm-proxy routes by name:

- value "anthropic/claude-haiku-4.5" -> OpenRouter -> honors cache_control
  (verified in proxy logs: 6841-tok prefix, cache_write then cache_read,
  ~12x cheaper on the cached prefix)
- value "claude-haiku-4-5" -> Anthropic-direct OpenAI-compat endpoint ->
  ignores message-embedded cache_control (prompt_tokens_details: None)

The prior note steered users to 'Anthropic-routed models', which is the
route where the flag does nothing. Rewrite to nudge Claude entries to the
anthropic/ OpenRouter model id + prompt_cache: true, with the measured
numbers and the routing table.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 56.63% 4949 / 8738
🔵 Statements 56.61% 4949 / 8742
🔵 Functions 63.6% 180 / 283
🔵 Branches 83.74% 1082 / 1292
File CoverageNo changed files found.
Generated in workflow #162 for commit 26b8d64 by the Vitest Coverage Report Action

@cboettig
cboettig merged commit aadb2cf into main Jul 10, 2026
1 check passed
@cboettig
cboettig deleted the docs/prompt-cache-openrouter-route branch July 10, 2026 20:17
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.

1 participant