Skip to content

Add support for OpenRouter Response Caching #853

@Aaronontheweb

Description

@Aaronontheweb

Overview

OpenRouter launched Response Caching — a feature that enables caching of identical API requests so responses return in a fraction of the time at zero cost.

What it is

Response Caching stores the output of LLM API calls and serves cached responses for subsequent identical requests. This is particularly useful for:

  • Repeated system prompts — Netclaw uses consistent system prompts (AGENTS.md, SOUL.md, skills) across sessions
  • Common tool definitions — Tool schemas are sent with every request and rarely change
  • Frequent recurring queries — Reminders, webhooks, and scheduled tasks often reuse the same prompt structures
  • Memory retrieval context — Repeated memory lookups with similar queries

How to enable

Two methods:

  1. Request header: Add x-response-cache-control: cache to API requests
  2. OpenRouter Presets: Enable via the OpenRouter presets UI for specific models

Why this matters for Netclaw

Netclaw makes a high volume of LLM API calls:

  • Every session turn sends system prompt + tool definitions + conversation history
  • Reminders fire autonomously with structured prompts
  • Webhooks process inbound payloads through LLM analysis
  • Memory operations (find/store) generate API calls

Many of these involve repetitive prompt structures that would benefit significantly from caching.

Proposed implementation

  1. Add a configuration option for enabling response caching per provider/model
  2. For OpenRouter providers: Support the x-response-cache-control: cache header
  3. Consider prompt prefix caching where applicable (e.g., Anthropic's caching headers)
  4. Surface cache hit/miss metrics in session or debug output
  5. Respect model-level caching support — not all models on OpenRouter may support this

References

Type

Enhancement / Cost optimization

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions