Caching

To enable caching, you can use the CacheControl object when defining the parts of a message.

Learn more about how caching works in OpenRouter

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Based on the book text below:"
    },
    {
      "type": "text",
      "text": "HUGE TEXT BODY HERE",
      "cache_control": {
        "type": "ephemeral"
      }
    },
    {
      "type": "text",
      "text": "List all main characters mentioned in the text above."
    }
  ]
}

Last updated

Was this helpful?