Enable caching for a request
Set thewandb-cache-mode request header to one of the following modes:
To bypass the cache, omit the header.
For compatibility with OpenPipe clients, the proxy also accepts the deprecated
op-cache header. It takes the same modes, plus true as an alias for readWrite and false to bypass the cache. If a request sends both headers, they must select the same mode. Otherwise, the proxy returns 400 Bad Request.
- Python
- JavaScript
- cURL
readWrite or readOnly), the response includes a wandb-cache-status header with the value hit or miss. The proxy sends the same value in the x-wandb-cache compatibility header. The response to a writeOnly request doesn’t include either header.
What makes two requests identical
The proxy looks up a cached response after it resolves the project version and routing revision, and before it selects a provider. The cache key combines the following values:- The W&B entity, project, and project version that the proxy resolves from the
modelvalue. - The routing revision that applies to the version when the request arrives.
- The request path and query string.
- A SHA-256 hash of the request body, serialized with object keys in sorted order and with the following values excluded.
- The raw
modelstring. Its resolved project, version, and routing revision are already in the key, so only equivalent references share entries:ticket-classifierandticket-classifier@v1both resolve to version 1. Different versions never share entries. - Metadata keys that start with
wandb., includingwandb.entityandwandb.thread_id. stream: false, which the proxy treats the same as omittingstream.- An empty
metadataobject, which the proxy treats the same as omittingmetadata.
messages, tools, tool_choice, response_format, temperature, top_p, max_tokens, seed, n, stop, user, any provider-specific fields, and metadata keys that don’t start with wandb., such as gen_ai.conversation.id or user.id. The order of keys within an object doesn’t matter. The order of items in an array, such as messages, does.
Entries are scoped to your W&B entity and project. An identical request from another entity, or for another project in your entity, never matches your entries.
A cached response records the routing target that produced it. The proxy serves a hit from that target without weighted or sticky routing.
Direct provider/model requests can also set a cache header. The proxy keys their entries separately by entity, provider, model reference, and the caller’s W&B identity. These entries never match project entries.
Limits
The cache has the following limits:- Non-streaming requests only. Requests with
stream: truethat set a cache header return400 Bad Request. - Successful responses only. The proxy stores only 2xx responses up to 8 MiB.
- Retention is 7 days. Entries are deleted 7 days after they’re written. Hits don’t refresh them.
- Invalid modes are rejected. Any
wandb-cache-modevalue other than those listed, or conflicting modes inwandb-cache-modeandop-cache, returns400 Bad Request.
Traces and Analytics
The proxy still records a cache hit as a project trace. The trace keeps the original response and its token usage, is marked withcache_hit=true, and has no provider latency. A request that enables cache reads but is forwarded to the provider is marked with cache_hit=false.
Analytics counts the provider spend of a cache hit as zero, because no inference ran, while token totals still include the replayed usage. Dataset creation deduplicates identical inputs, so replayed responses don’t add duplicate training rows.
Browser clients
The proxy allows thewandb-cache-mode and op-cache request headers in cross-origin requests, and it exposes wandb-cache-status, x-wandb-cache, and x-proxy-request-id to browser code.
Chat Completions
See how the proxy builds the provider request, handles streaming, and forwards tools and structured output.