← All Plugins
AI Optimization

Semantic Caching

Answer repeat questions from cache, not from the model.

Semantic Caching lets Agent Router (EAIG) recognize when a new prompt means the same thing as one it has already answered, and return the stored response in milliseconds instead of paying for another model call.

What Semantic Caching does

What it does

The plugin converts each incoming prompt into an embedding and compares it with prompts that have already been answered. When a stored prompt is similar enough, Agent Router returns the cached response. When nothing matches, the request continues to the model and the new response is stored for next time.

The enterprise problem

Enterprise AI traffic is highly repetitive: support assistants, internal copilots, and RAG applications receive the same questions phrased in many different ways. Exact-match caches miss these, so every variation becomes a full, billable model call with full model latency.

Where it fits in Agent Router

Semantic Caching runs inside Agent Router, after authentication and before routing to a provider. Because it sits at the gateway, every application behind Agent Router benefits without changing application code or SDKs.

How It Works

The request and response flow

  1. 1
    Request

    Request arrives at Agent Router

    An application sends a chat or completion request. Agent Router authenticates it and identifies the route, model, and tenant.

  2. 2
    Request

    Prompt is embedded

    The plugin normalizes the prompt and generates an embedding using the configured embedding model.

  3. 3
    Request

    Similarity evaluation

    The embedding is compared against cached entries scoped to the same route, model, and tenant. The closest match is scored against the similarity threshold.

  4. 4
    Response

    Cache hit: respond immediately

    If the score meets the threshold and the entry is within its TTL, the cached response is returned with a cache-status header. No provider call is made.

  5. 5
    Response

    Cache miss: call the model and store

    Otherwise the request is routed to the LLM provider as normal. The response is returned to the application and written to the cache with its embedding and TTL.

Architecture

Semantic Caching in Agent Router

Semantic Caching architecture: Support assistants, Internal copilots, RAG applications, AI agents send requests to Agent Router, which applies Prompt embedding, then Similarity evaluation, then Threshold & TTL check, and connects to Cached response, LLM provider, Cache store, Metrics.ApplicationChat · RAG · agentsAgent RouterSemantic CachingEmbed promptNearest-match lookupSimilar?score ≥ 0.92Cache hitCached responseReturned in milliseconds · no tokensResponse to applicationCache missLLM providerOpenAI · Anthropic · Bedrock · vLLMStore response + TTLCache storeEmbedding · response · TTLSimilar entries
Applications
Support assistantsInternal copilotsRAG applicationsAI agents
Agent Router
Semantic Caching plugin
Prompt embedding
Similarity evaluation
Threshold & TTL check
Outcomes
Cached responseCache hit
LLM providerCache miss
Cache storeStore new response
MetricsHit rate · tokens saved

Similar prompts are answered from the cache. Misses go to the provider and are cached on the way back.

Key Features

Built for production AI traffic

Embedding-based matching

Matches prompts by meaning rather than exact text, so rephrased questions still hit the cache.

Tunable similarity thresholds

Set how close a match must be per route, from strict thresholds for factual answers to looser ones for FAQs.

TTL and invalidation

Expire entries by age, and clear them by route or tenant when source content changes.

Scoped cache keys

Entries are isolated by tenant, route, and model so one team never receives another team's cached answer.

Selective bypass

Skip caching for streaming, tool calls, or requests carrying a bypass header.

Cache observability

Hit rate, latency saved, and tokens avoided are exported as gateway metrics for dashboards and FinOps.

Benefits

Engineering and business outcomes

Cost

Fewer billable model calls

Every cache hit is a request that consumes no input or output tokens at the provider. Savings grow with how repetitive your traffic is.

Latency

Millisecond responses on hits

Cache hits skip model inference entirely, turning multi-second completions into near-instant responses.

Reliability

Less exposure to provider limits

Fewer upstream calls means less pressure on provider rate limits and quotas during traffic spikes.

Developer experience

No application changes

Caching is enabled per route at the gateway. Teams get the benefit without adding cache logic to every service.

Use Cases

Where enterprises use Semantic Caching

01

Customer support assistants

Thousands of customers ask about the same refund, shipping, or password-reset policies in different words.

02

Internal knowledge copilots

Employees repeatedly ask about HR policies, onboarding steps, and engineering standards.

03

RAG over stable documentation

Product documentation and runbooks change rarely, so answers can be reused safely within a TTL.

04

Classification and tagging pipelines

Batch jobs that classify similar tickets, emails, or log lines avoid re-sending near-duplicate prompts.

Configuration

Enable semantic caching on a route

Embedding modelModel used to turn each prompt into an embedding for comparison.
text-embedding-3-small
Similarity thresholdHow close a new prompt must be to a cached one to count as a hit. Higher is stricter.
0.92 (cosine)
Cache TTLHow long a cached response can be reused before it expires.
6 hours
Cache scopeKeeps cached answers separate so one team never receives another team's response.
Tenant · route · model
Maximum entriesUpper bound on stored responses before the oldest are evicted.
50,000 per route
Bypass rulesRequests that always skip the cache and go straight to the model.
Streaming, tool calls, x-cache-bypass header

Illustrative example. Settings and values show what can be configured and are not exact configuration syntax.

Enterprise Workflow

How it fits your AI platform

  1. 01

    Platform team

    Enables Semantic Caching on selected Agent Router routes and sets thresholds and TTLs per use case.

  2. 02

    Applications

    Call Agent Router exactly as before, using the same OpenAI-compatible API.

  3. 03

    Agent Router

    Authenticates the request, runs the cache lookup, and serves hits directly.

  4. 04

    Models & providers

    Receive only cache misses, so paid inference is reserved for genuinely new questions.

  5. 05

    FinOps & SRE

    Track hit rate, tokens avoided, and latency saved from gateway metrics.

Cut LLM cost and latency with Semantic Caching

IMESH can help you identify cacheable traffic, tune similarity thresholds, and roll out Semantic Caching on Agent Router (EAIG).