Blog

How an inference platform fits together

Markdown

How gateways, routing, caching, and model serving interact, and how request context can carry through those layers.

MAR 08, 2026 | Engineering | 4 min read

How gateways, routing, caching, and model serving interact, and how request context can carry through those layers.

A request context can travel through a gateway and router into model serving. That context ties model choice, cache reuse, and execution to the caller's identity and the cost of each attempt. A router that ignores cache state can spend the savings its neighboring layer made.

Sharing context costs integration work, and a router that reads cache state is harder to swap. Sending context with the request while keeping the products separate lets a team use a gateway and router on another provider's runtime. The router then makes decisions with the information that provider exposes.

  1. Gateway — The application contract
  2. Route + cache — Choose and reuse work
  3. Model serving — Execute the model
  4. Application — Validate and use the result
Trace the request · Evaluate its outcome · Improve the cause
One request · shared context · The endpoint is one part of the system.

A cheaper route can cost more

Consider an illustrative document-extraction service with long fixed instructions and a short document on each request. Prefix caching and routing both look attractive, and each can undercut the other. A cached prefix is key-value state computed by one model, so a request routed to another model reads the instructions from scratch.

Anthropic's published five-minute cache pricing is 1.25 times base input for a write and 0.1 times for a read, with per-model exceptions (announcement, documentation). Against that warm cache, an uncached alternative has to charge less than a tenth of the incumbent's input price to win on the shared prefix. One write and one hit cost 1.35 input passes on the cached portion, against two without caching. A write that no later request reads costs 1.25.

A router comparing list prices might see a model at half the input price and switch, paying at least five times as much for the prefix. Declared routing states which models may substitute; shared context shows what each substitution cost.

Answer reuse needs the caller's identity

  1. Exact response — Reuse an answer for a matching request
  2. Prefix — Reuse input computation, generate a new answer
  3. Semantic — Decide when different requests are equivalent
Reuse must respect the model, prompt, schema, and freshness requirements.
Three different kinds of reuse · An answer cache is not a prefix cache.

An answer cache returns a stored output; a semantic cache also decides when two different requests deserve the same one. GPTCache decides hits by embedding similarity, and its README warns of “false positives during cache hits.”

In extraction, a false positive could return a wrong account number: two invoices from one vendor template can sit close in embedding space, and the cache may hand the second invoice the first one's account. A semantic cache without application identity can create a correctness bug, while its hit-rate dashboard counts each wrong answer as a saving.

Anthropic isolates prompt caches between organizations, and per workspace on its own API, though a prefix cache hands back no stored answer. An answer cache needs at least that boundary. An application can declare whether a task tolerates reuse across similar inputs, and reuse can key on the caller, the data that caller may read, and the task version.

Extraction can use exact-match reuse or none, with an unknown key triggering recomputation. That rule lowers hit rates and pays for work a looser cache would skip. The default may be too strict: across a large public FAQ, recomputing on unknown keys may cost more than the rare wrong answer it prevents.

Follow the failure before choosing the fix

Suppose a cheaper model returns invalid fields and a larger model repairs them, increasing that document's bill and delay. Cost can be counted per correct extraction at the required latency; the first call's token price is one input.

Berkeley's compound AI systems analysis argues for optimizing interacting components together. A trace has to separate a model failure from stale reuse, a slow tool, or a bad route, since each points to a fix in a different layer. Control over execution can help identify where costs arise, while a faster runtime may shift waste into the decisions around it. Connecting traces to evaluation on production traffic can test whether a change improves the task, including the recovery path.

An operator can use that trace to change the layer that failed. Keeping request history, evaluation cases, and deployment choice within the customer's application lets improvements build on that application's own experience.

  • guide
  • platform
  • inference
  • ops

With 1,284 models and variants across 15 categories, Ailoot is one of the world’s largest AI routers by model count. Explore Ailoot’s LLM API with a key issued by Ailoot. Choose Claude or Qwen for code, FLUX for images, Kling for video, Scribe for transcription, Lyria for music and Tripo3D for 3D assets. BGE embeddings support semantic search.

Give your product access to leading text, code and media models through the Ailoot API. Put reasoning with Claude, image generation with FLUX and video with Kling into one workflow.

A commercial licence from Ailoot covers your own paid software. Give projects their own keys and manage company usage from an Ailoot workspace.

One subscription covers the full Ailoot catalogue. With day-one access to new flagship models, you can keep using the same key when a new model arrives. Visit https://ailoot.ai/ for subscriptions and promo codes offering up to 50% off official provider API prices.