How to Build a Traffic-Aware LLM Inference Platform on Kubernetes with Prefix-Cache-Aware Routing and OpenRouter Fallback
In this article, you'll learn how to build a multi-model inference serving platform on Kubernetes. You'll serve two models—one with a single replica and another with two—across a total of three GPUs.
You'll use the Gateway API Inference Extension (GIE) to route traffic to those models based on metrics such as prefix-cache affinity and the user's model selection. You'll also configure pi as the client to test the setup end to end through a single OpenAI-compatible endpoint.
One thing to remember before moving forward: no matter how powerful your GPUs are or how much you've spent on the infrastructure for your local AI inference platform, announcing to your teams, "Hey everyone, you can now use the best open models with unlimited tokens. GLM 5.3-753B is available at example.com/v1/glm/53, KIMI-k3-2.8T is at example.com/v1/kimi/k3, and every model has its own endpoint," will likely not go over well.
In fact, quite the opposite. People don't want to memorize ten different endpoints per model. They just want to select models using their harness with /model and get on with their tasks. Requiring model-specific endpoints makes an AI platform harder to adopt—and it's one of the issues we'll fix in this article.
Who This Article Is For
- Platform engineers building a local AI inference serving platform.
- Anyone interested in prioritizing local GPUs for inference and falling back to the cloud when local GPUs aren't available.
What You'll Get From This Guide
- How to build and observe a multi-model inference platform on Kubernetes.
- Terraform and Kubernetes artifacts to provision and destroy the setup on Google Cloud.
- How to route LLM traffic to the correct model and pod replica using different routing strategies.
- Why a unified OpenAI-compatible endpoint matters for platform adoption—and how to implement it with OpenRouter fallback when local capacity is exhausted.
Note: As of 2026, Gateway API Inference Extension (GIE) has matured into the standard mechanism for inference-aware routing in Kubernetes. Prefix-cache-aware routing significantly reduces time-to-first-token (TTFT) for conversational workloads by preferring replicas that already hold the relevant KV cache. Pairing GIE with an OpenRouter fallback provides a resilient architecture: local GPUs absorb steady-state traffic, while cloud inference handles overflow and cold-start spikes.
via FreeCodeCamp
