The Problem: Every Model Swap Breaks Your Client Code
If you've shipped an AI feature in the last year, you know the pain. You hardcode an endpoint. Six months later a cheaper, faster model drops, and suddenly you're refactoring auth, payload schemas, and retry logic across every service that calls the LLM.
The industry answer is the LLM gateway pattern — a centralized, serverless ingress that accepts OpenAI-compatible requests and fans them out to whichever backend you want. Google Cloud just shipped model routing in API Gateway (Public Preview), and it's a genuinely lightweight take on the idea.
What makes it interesting isn't the routing itself — proxies have done that for years. It's that the gateway transcodes the payload to the native schema of each backend and injects the Agent Platform auth token for you. Your client keeps speaking OpenAI; the backend hears native Gemini or Anthropic.

How It Works: Backends, Routers, and Paths
The config lives entirely in your OpenAPI 3.x spec via the x-google-api-management extension. Three concepts do all the work:
- backends — named upstream targets (Gemini, Claude, OSS-GPT) with an address, deadline, and
pathTranslation: CONSTANT_ADDRESS. - routers — a
defaultModelplus aruleslist that maps a requestedmodelstring to a backend. - paths — your public endpoints, each tagged with
x-google-model-router.
Here's the minimal shape:
x-google-api-management:
backends:
gemini-35-flashlite:
address: >-
https://aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash-lite:generateContent
deadline: 60.0
pathTranslation: CONSTANT_ADDRESS
anthropic-claude-opus-47:
address: >-
https://aiplatform.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/publishers/anthropic/models/claude-opus-4-7:rawPredict
deadline: 60.0
pathTranslation: CONSTANT_ADDRESS
ai:
models:
routing:
routers:
gemini-claude-router:
defaultModel:
backend: gemini-35-flashlite
targetModel: google/gemini-3.5-flash-lite
rules:
- model: "claude-opus-4-7"
backend: anthropic-claude-opus-47
targetModel: anthropic/claude-opus-4-7
Then expose it as a normal POST path:
paths:
/v1/chat/gemini-claude:
post:
summary: "Endpoint: defaults to Gemini, Claude as an option."
operationId: "chatGeminiClaude"
x-google-model-router: gemini-claude-router
responses:
'200':
description: "OK"
Deploy the config, and your client code never changes again:
curl -X POST "https://my-gateway.example.com/v1/chat/gemini-claude" \
-H "content-type: application/json" \
-H "x-api-key: $API_KEY" \
-d '{
"model": "claude-opus-4-7",
"messages": [{"role": "user", "content": "Introduce yourself in 5 words"}]
}'
The gateway intercepts the request, transcodes the OpenAI-shaped body into Anthropic's native schema, attaches the Agent Platform token, and routes it. You get back a response; you never touched a proxy.

Comparison: Where This Fits vs. Rolling Your Own
| Concern | Roll-your-own proxy | Cloud API Gateway model routing |
|---|---|---|
| Infra to operate | Yes (containers, scaling, TLS) | Serverless, managed |
| OpenAI-compatible ingress | Build it yourself | Built in |
| Schema transcoding (OpenAI → Gemini/Anthropic) | Custom code per backend | Handled by gateway |
| Backend auth rotation | Touches every client | Isolated at gateway |
| Rate limiting / token tracking | Add-on | Native |
| Cross-host routing | Flexible | Not supported — all backends in a router must share a host |
| Cost | Infra + ops time | Gateway pricing |
The Limitations You Should Know
- Single host per router. All backends referenced by one router must share the same host (e.g.,
aiplatform.googleapis.com). This is not a general-purpose multi-cloud router — it routes models and paths on a shared Agent Platform host. - Public Preview. Expect API surface changes. Don't put this in a compliance-critical path yet.
- Rules-based only. Routing decisions are driven by the
modelfield and static rules — no latency-aware or cost-aware dynamic routing (yet). - Auth split is a feature, but it's a footgun too. Because clients authenticate to the gateway, not the model provider, a misconfigured gateway is a single point of credential exposure. Treat the gateway API key as a production secret.
If you're already deep into Apigee or need agent-level governance, the broader AI gateway spectrum (Agent Gateway, Gemini Enterprise Agent Platform) is where you'll graduate. Start lightweight here; grow into the rest when the requirements actually arrive.

The Takeaway
The LLM gateway pattern has been the pragmatic answer to model churn for a while — the question was always who operates it. Google Cloud API Gateway's model routing makes the boring parts (schema transcoding, auth injection, rate limiting) someone else's problem, and gives you a stable OpenAI-compatible endpoint to point your apps at.
Next steps to actually learn this:
- Deploy a single-router config against a dev project and hit it with
curl— feel the transcoding. - Add a second router and test the
modelfield override. - Read up on the broader AI gateway spectrum (Apigee, Agent Gateway) to know when to graduate.
If you're still building the model-serving layer underneath, the distributed communication primitives matter just as much — see our PyTorch distributed communication deep dive for the point-to-point and collective ops that make multi-GPU training work. And if you're tracking the hardware side of the AI stack, Azure's NVIDIA Rubin datacenter buildout is worth a read.