Skip to main content
The semantic_cache policy serves cached completions for repeated requests — either exact (normalized text equality), semantic (embedding similarity), or both. It embeds the prompt, looks for a close match in the configured vector store, and returns the cached response on a hit. It runs in two stages: pre_request (lookup) and post_response (populate).

Settings

On a hit

The cached response is returned and the proxy sets cache headers (X-Cache-Status: HIT and a similarity score). To skip the cache for a single request, send the configured bypass_header (default X-Cache-Bypass); the fresh response still populates the cache.
Tune similarity_threshold carefully: too low risks serving a cached answer for a meaningfully different prompt; too high reduces hit rate. Start at 0.9 and lower it while watching answer quality.