Skip to main content
AI on Kubernetes · GPU/NPULesson 13 of 20

From API Request to Response

Once a model server is ready, clients call it through an OpenAI-compatible API. One request travels load balancer → API gateway → routing → model server and back. Along the way, see where requests with a bad key or over their limit are stopped.

Key check—
Usage limit—
Tokens—
Key management · authInference clusterClient appe.g. chatbotKey serviceissues API keysAuth serviceexternal authzLoad balancerexternal entryAPI gatewaykey + limit checkRoutingpicks a replicaReplica 1vLLMReplica 2vLLMAccess logs401 / 429 recordsAPI key (shown once)
RequestResponse / reportAppears in a later step

What you will learn

  • The raw API key is shown only once, at issue time
  • How the gateway checks the key on every request
  • Paths that bypass the gateway must be blocked
  • Token limits are charged after the response ends

Where requests get stopped​

SituationStopped atResponse
Missing, wrong, or revoked keyAPI gateway (auth service)401
Over the limitAPI gateway429
All replicas busyModel server queueSlow first token
Bypassing the gatewayNot stopped without a NetworkPolicyPasses through

Try it yourself​

curl -s http://<gateway>/v1/models -H "Authorization: Bearer $API_KEY" # OpenAI-compatible API, e.g. vLLM (step 2)
curl -s -o /dev/null -w '%{http_code}\n' http://<gateway>/v1/models # No key: expect 401 (step 3)
curl -sN http://<gateway>/v1/completions -H "Authorization: Bearer $API_KEY" -H 'Content-Type: application/json' -d '{"model":"<model>","prompt":"Hello","max_tokens":32,"stream":true}' # Tokens stream back (step 7)
kubectl get networkpolicy -n <namespace> # Only the gateway reaches model Pods (step 4)
curl -s http://<engine>:8000/metrics | grep -E 'vllm:(num_requests_waiting|time_to_first_token_seconds)' # Replica queue and TTFT

Check yourself

  1. Requests without a key get 401 at the gateway, yet someone inside the cluster is calling the model with no key. What is most likely?
  2. You revoke an API key, but it keeps working for a short while. Why?
  3. A key's actual token usage ends up slightly over its tokens-per-minute limit. Why can that happen?

Further reading: Network Policies · Gateway API · Gateway API Inference Extension