Answer a repeated request from a kept copy — word for word, at 0 DA.
When your application sends the same request more than once, OpenDunes can answer it from a kept copy instead of running the model again. The copy comes back word for word, costs 0 DA, and arrives without the model's wait.
The cache is off unless a request, or its preset, turns it on. Turn it on with a header:
curl https://opendunes.com/v1/chat/completions \
-H "Authorization: Bearer $OPENDUNES_API_KEY" \
-H "Content-Type: application/json" \
-H "X-OpenDunes-Cache: true" \
-d '{
"model": "anthropic/claude-haiku-4.5",
"messages": [{ "role": "user", "content": "List the 58 wilayas of Algeria." }]
}'| Header | Does |
|---|---|
X-OpenDunes-Cache | true turns the cache on for this request, false turns it off — the request's word wins over its preset's |
X-OpenDunes-Cache-TTL | how long to keep the copy, in seconds, from 1 to 86 400. Default 300. Any other value is a 400 |
X-OpenDunes-Cache-Clear | true runs the model anyway and replaces the kept copy |
A preset saved from a request that carried these headers turns the cache on for every request that uses it.
The same key, the same model, the same route, the same streaming choice and the same body — and, with a preset, the same version of it. A copy is returned word for word, whatever the temperature. One key's copies are never another key's.
Four routes cache: /v1/chat/completions, /v1/responses, /v1/messages and /v1/embeddings. A streamed answer is kept too, and a copy of it streams back. Only a successful answer is kept.
| Header | On |
|---|---|
X-OpenDunes-Cache-Status | MISS when the model ran and its answer was kept, HIT when the answer is a copy |
X-OpenDunes-Cache-TTL | seconds the copy has left |
X-OpenDunes-Cache-Age | on a hit: seconds since the copy was kept |
X-OpenDunes-Cache-Source-Id | on a hit: the receipt id of the request that made the copy |
A hit costs 0 DA and runs no model. It still passes your key, its guardrails and the balance check, and it is sent to your Broadcast destinations like any request.
Two identical requests at the same instant both run, and both are billed.
The response cache keeps a whole answer and skips the model. Prompt caching is the provider's: the model still runs, and the part of the prompt it has seen before is billed at a lower rate.