LLM egress router · one door, three Gemini tiers, a guard on both sides

agentgateway front (Keycloak JWT · guard webhook · token budget · cost log) → vLLM Semantic Router (domain + keyword signals) → agentgateway egress → Vertex AI · guards = presidio-guard + nemo-guard (two deployments) · ledger in Postgres over OTLP · ops-chat (React + FastAPI) registers MCP servers and runs their tools through the MCP gateway of project 1
CALLERS · one token, two doors THE LLM DOOR · llm.jainosoft.com · namespace llm VERTEX AI · cloud models only ops-chat React 19 + FastAPIchat.jainosoft.com · OIDC · PostgresMCP servers registered per user any OpenAI SDKbase_url = llm.…/v1 · model auto n8n · agents · CIsame Keycloak token MCP gateway · project 1mcp.jainosoft.com · CEL per roleops-chat's tools run as the userk8s · ops-db · gcp · github tools Cloudflare TunnelTLS at the edge · no public IPshared with project 1 agentgateway · front :4000 1 · identityKeycloak JWT · aud agentgateway401 without it 2 · guards (request)presidio-guard masks PII · countsnemo-guard self-check-input blocks400 on jailbreak 3 · budget50k tokens / user / hour429 when spent 5 · guards (response)presidio-guard masks the answernemo-guard self-check-output ledger · Postgresaccess log (OTLP) + guardsuser · model · tokens · cost 4 · vLLM Semantic Router v0.4 Envoy ext_proc · ~130 ms to decide signalsdomain classifier (MMLU: math, physics,chemistry, engineering, CS, other) + keywords decisions (priority) coding → gemini-3.8-flashreasoning → gemini-3.8-flashsimple_chat → gemini-3.5-flash-litegeneral → gemini-3.5-flashdefault → gemini-3.5-flash response headers: x-vsr-selected-decision,x-vsr-selected-model, routing latency semantic cache (memory) · the router neverholds a cloud credential: every tier is analias for the egress → agentgateway · egress :4100 cluster-internal · Workload Identity (sa-llm-gateway, aiplatform.user) from the routertier chosen per prompt from the frontpinned tiers (comparison drills) from the guardNeMo's judge model (flash-lite) one listener = one place where everyGemini call of the platform is metered:gen_ai.request.model · tokensagw.ai.usage.cost.total gemini-3.5-flash-litecheapest · small talk, rewrites$0.10 / $0.40 per 1M gemini-3.5-flashdefault · general questions$0.30 / $2.50 per 1M gemini-3.8-flashstrongest · code, maths, reasoning$0.50 / $3.00 per 1M no GPU, no self-hosted model:the switching is the project,the tiers are whatever the cloud sells. MEASURED (recorded run) ·····
a normal prompt: guard pass → router → tier → answer, logged with costa prompt with personal data: masked before the model, counteda jailbreak: refused at the door, no model involved
bhavishyajain545 · gcp-ai-llm-router