Response cache
Replay a stored answer to an identical request on Chat Completions, Responses and Messages, turned on per request, per key or for the whole organization.
What it does
The response cache stores a complete, successful answer and replays it, unchanged, when the same request comes again. A hit never reaches a model or a provider, so it answers in milliseconds and is never charged provider cost. It works on all three text APIs.
It is not prompt caching. Prompt caching is the provider reusing a prompt prefix: the model still runs and you pay for the output. The response cache skips the model entirely and returns the stored answer, so use it only where the same request should get the same answer (tests, evals, repeated lookups, idempotent pipelines).
POST/v1/chat/completionsPOST/v1/responsesPOST/v1/messages| Prompt caching | Response cache | |
|---|---|---|
| What is reused | A prompt prefix, at the provider | The whole answer, at the gateway |
| Does the model run | Yes | No |
| You pay | Cached input rate, then output | The hit price (free today) |
| Turned on by | The route (automatic or cache_control) | You: a header, a key or the organization |
| Response header | Cached tokens in usage | X-Explabs-Cache: HIT |
Turn it on for one request
Send X-Explabs-Cache: true. The first call answers from the model and saves the answer (X-Explabs-Cache: MISS); the same call again is replayed (X-Explabs-Cache: HIT, with a fresh x-request-id). No header in the response means the cache was not used.
| Request header | Values |
|---|---|
X-Explabs-Cache | true reads and saves for this request; false bypasses the cache whatever the settings say |
X-Explabs-Cache-Ttl | Seconds a saved answer stays readable, 1 to 31,536,000 (365 days). Default the organization's time to live, else 7 days |
X-Explabs-Cache-Seed | Up to 128 printable characters. A different seed never shares an entry, so it partitions the cache (one per test run, for example) |
An unreadable value is refused with 400 invalid_cache_header before the call. These headers stay at the gateway and never reach the provider.
curl -si https://api.experientiallabs.ai/v1/chat/completions \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-H "X-Explabs-Cache: true" \
-H "X-Explabs-Cache-Ttl: 86400" \
-d '{"model": "gpt-6-luna", "messages": [{"role": "user", "content": "Capital of Japan?"}]}' \
| grep -i '^x-explabs-cache'
# first call: x-explabs-cache: MISS
# second call: x-explabs-cache: HITTurn it on for a key or the organization
Without the header, a key's mode decides, then the organization default. The request header always wins: X-Explabs-Cache: false bypasses a cache the key or organization turned on.
| Level | Where | Values |
|---|---|---|
| Request | X-Explabs-Cache header | true, false |
| API key | API Keys page, or the key route | follow (default), on, off |
| Organization | Settings > Data controls, or the organization route | On or off (off by default), with a default time to live |
The organization setting is written by org admins; a key's mode by the key's creator or an org admin. Both routes also take the organization's own key, so an agent can turn the cache on. Changes are audited and reach the gateway within seconds. GET on the organization route also returns blockers (why the cache cannot apply right now: unverified, quarantined, capture_off, zero_data_retention) and the plan's hit_price.
/api/orgs/{org_id}/response-cachePUT/api/orgs/{org_id}/response-cacheGET/api/orgs/{org_id}/keys/{key_id}/response-cachePUT/api/orgs/{org_id}/keys/{key_id}/response-cachecurl -X PUT https://api.experientiallabs.ai/api/orgs/ORG_ID/response-cache \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"enabled": true, "ttl_seconds": 86400}'What counts as the same request
A hit needs the same API (Chat Completions, Responses or Messages), the same body (JSON key order does not matter) and the same seed, sent with the same API key from the same country. Entries never cross organizations or keys, and a change to what the key may call (a newly blocked model, a narrower model allowlist) makes older entries a miss. A hit never replays an answer the caller could not have received.
Only complete, successful answers are saved: a 2xx with a whole JSON body, or a stream that reached its final event, at most 8 MiB. An error or a cut stream is never saved. A cached stream is replayed as one text/event-stream body; SSE clients parse it the same way.
| Same request | Miss |
|---|---|
| Same body with keys in another order | Any other field or message changes |
| Same key, same seed | Another key, another seed |
| Same country | A request from another country |
When nothing is cached
The cache follows your data controls: it never stores more than your organization stores. Nothing is read or saved when any of these holds.
| Case | Why |
|---|---|
| Prompt storage is off, or the organization requires zero data retention | A saved answer is stored content |
The key is set to Do not store, or the request sends X-Explabs-Storage (or Helicone-Omit-*) | The request asked to store less |
The request demands zero data retention (provider.zdr: true) | The same |
A Responses request with store: false, previous_response_id or background | Unstored, or the answer depends on earlier state |
| The key has IP rules | A hit could not check them |
| The organization is not verified (the card verification), or is under review | The cache is for verified organizations only |
Deleting stored content or turning storage off makes every saved answer unreachable at once. New saves are capped per organization (64 MiB or 5,000 entries per UTC day) and across the platform; past a cap the call is answered by the model as usual and simply not saved.
X-Explabs-Cache: falseHTTP/1.1 400 Bad Request
{"error": {"code": "invalid_cache_header",
"message": "X-Explabs-Cache must be true or false."}}Pricing
A hit dispatches nothing, so it never charges provider cost. What a hit itself costs is a plan setting with three modes: free, a fixed fee per hit, or a share of the cost the hit saved. It is free on every plan today. The price may change; the organization route's hit_price always states your current terms, and usage.cost on a replayed answer states what that hit was charged (0 while free).
hit_price.mode | A hit costs |
|---|---|
free (today, every plan) | Nothing |
per_hit | hit_nano_usd per hit |
saved_share | saved_share_bps basis points of the saved cost |
See hits in Observability
Every hit is a row in Requests, marked Cached, with zero tokens, the hit charge as its cost, and the cost it saved (what the original answer cost). The saved cost is never counted as spend. In the Request log API, an item carries cache_hit and cache_saved_usd.
/api/orgs/{org_id}/usage/requests{
"request_id": "req_01JD8ZK4M2Q7V9X3N5T6B8C0EF",
"model": "gpt-6-luna",
"cache_hit": true,
"cache_saved_usd": 0.0000129,
"input_tokens": 0,
"output_tokens": 0,
"cost_usd": 0
}Coming from Helicone
This is the same cache that serves the Helicone-Cache-* headers on Helicone hostnames, now on the main gateway too. On our base URL use X-Explabs-Cache, X-Explabs-Cache-Ttl and X-Explabs-Cache-Seed. See Moving from Helicone.
| Helicone | Here |
|---|---|
Helicone-Cache-Enabled: true | X-Explabs-Cache: true |
Cache-Control: max-age=N | X-Explabs-Cache-Ttl: N |
Helicone-Cache-Seed | X-Explabs-Cache-Seed |
Helicone-Cache: HIT | X-Explabs-Cache: HIT |