跳到正文
原文
KenTheRogers· @KenTheRogers · X·· 7 小时前AI 评分56

OpenRouter 缓存请求头可复用完整响应并跳过模型调用

AI 导读

OpenRouter 支持通过 X-OpenRouter-Cache: true 缓存完整响应,重复发送相同请求时约 1 秒返回且费用为 $0。该方式不同于 Prompt caching,会完全跳过模型调用;缓存默认持续 5 分钟,也可通过 X-OpenRouter-Cache-TTL 延长至 24 小时。

正文 · 原文

⚡ @OpenRouter tip #6

Add the header X-OpenRouter-Cache: true and OpenRouter saves your entire response. Send the exact same request again and you get it back in about a second, for $0.

This is different from prompt caching. Prompt caching only discounts the repeated part of your input, and the model still runs. This skips the model entirely.

So if you're iterating during development you can turn this on to call the model without needing to pay for a new generation every time.

The cache lasts 5 minutes by default, up to 24 hours with X-OpenRouter-Cache-TTL.

来源:KenTheRogers · x.com