Skip to main content
Answer a repeated request from Model Gateway’s cache instead of calling the provider again. The cache is off by default; an organization admin turns it on per model, and callers can opt out per request.

How the exact cache works

The gateway stores a model’s complete reply and replays it when the same caller sends the exact same request again before the reply expires. Exact means every part of the request matches: messages, tools, sampling settings, output constraints, and whether it streams. What is cached:
  • Complete chat replies, unary and streamed, and embedding replies.
  • A streamed reply only when the stream finished normally with its usage known, and stayed under 2 MiB.
  • Not decisions, images, audio, or any other modality.
A cache hit doesn’t call the provider and creates no new provider spend. The reply carries the usage the original call reported.

Before you begin

  • You’re an organization admin, to turn the cache on for a model.
  • The model’s modality is chat or embedding. Settings offers the cache only for those.
1

Open the model's settings

In Model Gateway studio, open Models, select the model, and open its Settings tab.
2

Turn on the exact-answer cache

Under Exact-answer cache, switch from Off (default) to On. In Keep an identical answer for, enter how long to keep a reply, from 1 to 3,600 seconds.
3

Save the model

Select Save changes.

Control the cache per request

Callers can narrow the cache for one request with headers. The model’s setting is always the upper bound: a caller can shorten the time a reply is kept, never lengthen it. These headers are never forwarded to the provider.
Any value of x-gateway-cache other than bypass or no-store returns 400 with x-gateway-cache must be bypass or no-store. A x-gateway-cache-ttl that isn’t a whole number of seconds returns 400 with invalid x-gateway-cache-ttl.

Verify

  1. On the model’s Overview tab, Routing and health reads Exact-answer cache on, 60 s. for a 60-second setting.
  2. Send the same chat request twice, with the same key.
  3. A fresh reply has an x-gateway-model-wire header naming the provider API that answered. A reply served from the cache has no x-gateway-model-wire header, because no provider API was called.

Exact cache versus provider prompt caching

Providers such as Anthropic cache the start of a long prompt and bill those tokens at a lower rate. That is a separate feature, and the gateway keeps it separate. The gateway forwards cache_control markers to providers whose API reads them: the Anthropic Messages API (direct, on Vertex AI, or on Azure AI Foundry), Amazon Bedrock, OpenRouter, and a LiteLLM proxy. On Bedrock only {"type": "ephemeral"} is carried. Other provider APIs have no such marker, so the gateway drops it there.