BNK
A request through the factory
From a chat message to a GPU and back
A user types a question into a chat app. Follow that one request from the browser to a GPU and back. Four parts of the factory each make a decision on the way. The BNK data plane decides whether the packet may enter. The AI gateway decides who is asking, what they may spend and which model answers. The guardrail decides whether the prompt is safe. The endpoint picker decides which GPU does the work. Only then does a GPU spend any time on it.
- Request
- POST /v1/chat/completions · stream
- Prompt
- 1,912 tokens · 1,800 of them a shared system prompt
- Model
- northlight-chat → qwen3-32b on 3 GPU workers
- Rule of thumb
- the AI gateway picks the model, BNK picks the GPU
Read the whole lesson as text
1. The call
The chat app talks to the factory through one address: api.northlight.example, which resolves to 203.0.113.80. That address is a virtual IP that BNK announces to the network with BGP as a single /32 route. No server owns it. The BNK data plane, TMM, answers for it. The browser opens a TLS connection to it and sends the question as an HTTP/2 request in the OpenAI chat format. The request asks for model northlight-chat and wants the answer streamed.
- The browser opens a TLS connection to the factory's address and names the host it wants.
- Inside the encrypted connection, the app sends the conversation and asks for a streamed answer.
2. The border
TMM is the only way in. Before it reads any HTTP it runs the packet through the firewall policy. Then it ends the TLS session, so everything behind it sees plain HTTP. Now it can read the host name and find a route. The Gateway called northlight has a listener on port 443, and the HTTPRoute chat-edge attached to it says that requests for api.northlight.example go to the AI gateway. TMM opens its own connection to the AI gateway Pod and passes the request on.
- The firewall in TMM checks where the packet comes from and where it is going, and lets it in.
- TMM decrypts the request, reads the host name and finds the route for it.
- TMM opens its own connection to the AI gateway Pod and passes the request on, in plain HTTP.
3. Who is asking
The AI gateway is where the factory learns who sent this. It looks up the API key and finds the team that owns it. It sends the prompt to AI Guardrails and waits for a verdict. It checks that the team still has budget for a request this size. Last, it turns the name the caller asked for, northlight-chat, into a real model: qwen3-32b, which this factory runs on its own GPUs. Any of the first three checks can end the request. A request refused here has cost no GPU time at all.
- The AI gateway looks up the API key and learns which team is calling.
- It sends the text of the prompt to AI Guardrails and waits for the answer.
- Guardrails finds nothing wrong and says the prompt may go on.
- It checks that the team still has budget for a request this size.
- It turns the name the caller asked for into a real model that this factory runs itself.
4. Which GPU
The AI gateway knows the model. It doesn't know the GPUs. So it sends the request back to BNK, on an internal listener. This time TMM finds a route whose backend is an InferencePool, not a Service. A Service would mean: any Pod will do. An InferencePool means: ask its endpoint picker first. TMM holds the request and opens an ext_proc stream to the picker, the same gRPC protocol Envoy uses for external processors. It sends the headers and the body. The picker counts the prompt in tokens, compares it with what it knows about each worker and answers with one Pod address.
- The AI gateway sends the request back to BNK, now with the real model name in it.
- TMM finds a route whose backend is an InferencePool, which means: ask the picker first.
- TMM holds the request and sends its headers and body to the endpoint picker over gRPC.
- The picker reads the body and counts the prompt in tokens, the unit a GPU works in.
- It compares the three workers. gpu-2 already holds the start of this prompt and has room, so it wins.
- The picker answers with one Pod address: gpu-2.
5. To the worker
TMM now knows the Pod. It sends the request straight to 10.244.2.22 on port 8000. There is no Service in between and no second load balancer that could undo the picker's choice. On gpu-2 the request will find most of its work already done: the first 1,808 tokens of the prompt are the support bot's system prompt, and gpu-2 has seen them before.
- TMM sends the request directly to the Pod on gpu-2.
6. Prefill
Zoom into gpu-2. The vLLM server turns the messages into 1,912 tokens and puts the request in its waiting queue. The scheduler takes it out between two passes of the batch that is already running. Then it looks in the KV cache. The cache is cut into blocks of 16 tokens, and each block is found by a hash of its own tokens and everything before them. The first 113 blocks of this prompt are there. That leaves 104 new tokens. The GPU reads those in one pass, all at once. This pass is called prefill and it is why the first token takes longer than the ones after it.
- The vLLM server applies the model's chat template and turns the text into 1,912 tokens.
- The request joins the waiting queue. It is the only one there.
- Between two passes, the scheduler takes it out of the queue and adds it to the running batch.
- It looks for the prompt in the KV cache, block by block, and finds the first 113 blocks.
- The GPU reads the 104 new tokens in one pass, all of them at once.
- A pass means every layer of the model, so the cores read all the weights from GPU memory once.
- For each new token and each layer the GPU stores a key and a value, filling six more blocks.
- The worker announces the new blocks, so the picker knows what gpu-2 holds now.
7. Decode
The end of the prefill pass gives the first token of the answer. From here the model works one token at a time. Each pass takes the last token, reads all the weights again, looks back at the KV cache and produces the next token. That is decode. A pass costs about the same for one request as for four, because reading the weights is the expensive part, so all four requests in the batch get their next token from the same pass. Every new token leaves the worker at once as one line of the stream.
- The prefill pass ends with the first token of the answer.
- Now each pass makes one new token for every request in the batch.
- The new token's keys and values are added to the cache, so the next pass doesn't redo them.
- The server writes the token to the open response at once, as one line of a stream.
8. The answer goes back
Back in the factory view. The stream leaves gpu-2 and returns through the proxies it came in by. TMM tells the picker which worker really served the request and lets it watch the answer go by. The AI gateway reads the last chunk, which carries the token counts, and charges them to the team's budget. Then TMM encrypts each chunk again and the words appear in the user's browser one by one, 212 tokens in all.
- Each token travels from gpu-2 to TMM as its own small packet.
- TMM tells the picker which worker actually served the request.
- The stream goes back through the AI gateway, the way the request came.
- The last chunk carries the token counts. The AI gateway charges them to the team.
- TMM encrypts each chunk and sends it to the browser. The stream ends with [DONE].
Summary
One request, four decisions, one GPU. The firewall in TMM let the packet in. The AI gateway found the team behind the key, had the prompt checked, confirmed the budget and chose the model. The endpoint picker chose gpu-2 because it already held 1,808 of the prompt's 1,912 tokens and had room. On the GPU, prefill read only the 104 new tokens, and decode produced the answer one token per pass. Had any check failed, the request would have ended before a GPU spent a single pass on it.
Next lesson: Inside the LLM gateway