Skip to content
IQ

Caching

Two different caches touch your traffic, and they behave nothing alike. The first is the gateway's own response cache, which answers a request out of IQ's storage without calling a provider at all. The second is the provider's prompt cache, which still calls the provider but charges you a discounted rate for the part of the prompt the provider already had in memory. A gateway hit costs you nothing. A provider prompt-cache read costs less than a fresh input token but is not free. Conflating the two is the single easiest way to misread your bill, so this page keeps them apart throughout.

Gateway response caching

When the gateway can serve a request from its own store, it does, and no upstream call happens. Three behaviours are live.

Single-turn traffic is matched by an exact-match layer first and a semantic-similarity layer second, so a near-identical prompt from the same key group returns the stored response instead of paying for a fresh generation. Both layers are scoped per key group and per requested model, so one key group's traffic never serves another's responses and a response stored against one model id or alias is never replayed for a request that named a different one. The semantic layer matches by storing a numeric fingerprint (an embedding) of each cacheable prompt alongside the response, so a hit on this layer holds a fingerprint of your prompt as well as the response itself. Entries age out on a tiered schedule: about seven days for ordinary answers, one day for turns that declare tools, and one hour for turns that return a tool call. With Zero Data Retention on, the gateway does not cache your organization's traffic at all; see Caching and zero data retention below.

Multi-turn agent traffic is covered by a conversation-scoped layer, with a short TTL of five minutes by default and strict org isolation.

Streamed Chat Completions and Messages requests hit the cache too. IQ rebuilds the stream from the cached response in the endpoint's own format, so your client sees a normal stream. Streamed Responses API requests are not served from the cache.

A gateway cache hit is billed at zero. It is not exempt from your limits, though: the rate-limit and budget checks run ahead of the cache lookup, so a hit still counts against your per-minute request allowance. Size a replay-heavy workload against the request limit, not just the spend. Latency lands in the single-digit to low-double-digit millisecond range. A hit skips the provider round trip entirely, so it returns faster than the original request did. Requests marks each hit, so you can see exactly which traffic was served from cache. When routing telemetry is enabled, the reply can carry the same signal: the cache_hit field in the x-iq-routing header is true on a hit, so your own code can branch on it without a dashboard round-trip. See /docs/sdks/curl for a worked example of reading the header.

What still bypasses the gateway cache

A request that carries an image attachment is never looked up and never written. The cache key is built from text, so a content-blind key would let one image's description answer a question about a different image. Error-shaped responses are refused too: a reply with neither text nor a tool call is never stored, so a single upstream failure cannot poison a key for the rest of its TTL. Gateway-generated notices are refused on the same grounds.

Turns that carry tool calls are not excluded. An agent step whose output is a function call is a cacheable turn like any other, because the alternative was that agent traffic structurally never hit the cache at all. If a step in your loop carries a side effect, make the tool call idempotent on your side and treat a cached replay the way you would treat any retry.

Invalidation

A workspace owner, or an admin with permission to change routing policy, can use Clear my workspace's cache when Settings shows it. Otherwise, entries age out on their own schedule, one hour to seven days for the single-turn layers, depending on the turn, and five minutes by default for the conversation-scoped layer. The conversation layer keeps entries for up to an hour. It is not a workspace setting today.

The semantic layer uses one default similarity cutoff set by IQ and not exposed as a customer setting, so how close a paraphrase has to be to count as a hit is not something you tune. The cutoff is deliberately tight: a near-miss falls through to a fresh provider call rather than answering a different question.

Provider prompt caching

Provider prompt caching is a different mechanism owned by the upstream provider, not by IQ. The gateway passes it through, and each request's detail page shows its provider cache read and write tokens. The economics are asymmetric: writing a prompt into the provider's cache costs more than an uncached input token, and reading it back costs substantially less, so a cache that is written often and read rarely can cost you more than no cache at all.

The practical consequence is that a provider prompt-cache read shows up on your bill at a discounted rate, while a gateway cache hit shows up at zero. If you see cost on a request you believed was cached, check which cache you were counting on. The accounting detail, including how each token class is reported, lives on the billing page.

Cache protection

Cache protection keeps a conversation from needlessly throwing away a warm provider prompt cache. A request stays on the model whose cache is warm when reusing it is expected to make it the cheaper choice. The conversation moves only when another model is cheaper even after the cache is rebuilt, or when the warm model fails or no longer fits the request, such as a prompt past its context window. It stays inside your routing option: it never brings in a model that option would not already pick from, and never steps down to a weaker model because of the cache. Named models are unaffected, and the routing page covers how each option applies it.

To use it, send the same X-IQ-Session-Id header on every request in the conversation, so IQ can keep it together. Agent clients that send their own session id, such as Claude Code or Codex, also work. On each request's detail page, the dashboard shows the model IQ recorded, its input, output and thinking tokens, its provider cache read and write tokens, and its cost. A request answered from IQ's response cache carries a cache hit badge, and its provider cache read count is 0. The billing page explains each token class, and the security page covers how zero data retention applies to caching.

Cache protection is not a promise of savings; the dollar figure on each request is its metered cost.

Caching and zero data retention

Your organization's requests, responses and routing results are never shared with another workspace, including anything IQ caches for speed. With zero data retention on, IQ does not cache them at all: the gateway neither reads from nor writes to its response caches for your organization. Entries cached before you turned ZDR on are no longer served. They expire on their normal schedule. A workspace owner, or an admin with permission to change routing policy, can use Clear my workspace's cache when Settings shows it. The full boundary, including what is and is not persisted with ZDR on, is on the security page. Loop-detection metadata is covered by the retention boundary on the security page.

Cache hit rate

The cache hit rate on your dashboard is the share of input tokens served from a cache instead of being processed again.