What you will learn
- Name the parts of the API Platform Gateway and what each one does
- Match the on-prem ports to the parts that use them
- Explain where the gateway gets its configuration and where it keeps its state
- Follow a request through the router and the policy chain, and say what happens if the policy engine cannot answer
Before you start
- A tour of the control side and the data side Not started In progress Done
- AMS's two doors: the public API and the internal server Not started In progress Done
On this page
Agent requests pass through a gate. The gate checks who is calling, applies the rules, and only then lets the request through to the agent, a model vendor or a tool server. In Agent Manager that gate is the AI gatewayThe doorway for agent traffic to model vendors and tool servers. It runs each request through a chain of policies, such as keys, limits and guardrails, before passing it on.Analogy:Airside security and customs. ID check, bag scan, then the real boarding document.See it in the glossary, or APG. This lesson takes it apart. It is the same gateway that the lessons on LLM traffic and traces rely on, and now you will see its parts.
Two pieces, not one
APG is made of two Deployments that work as a pair.
- The Gateway-controllerThe local brain of one gateway. It dials Agent Manager over a WebSocket, downloads the gateway's configuration and keeps the router in step.See it in the glossary is the brain of one gateway. It talks to AMS and prepares configuration.
- The gateway runtime is one container that holds the Envoy routerThe proxy inside the gateway runtime that receives the requests and asks the policy engine what to do before it forwards them.See it in the glossary, which receives the requests, and the Policy engineThe part of the gateway runtime that runs the policy chain for each request. The router hands each request to it, and its policies are compiled in.See it in the glossary, which runs the rules. A small Python helper can run beside them when the image contains policies written in Python. In the Agent Manager setup the router and the engine talk to each other over a Unix socket inside the container.
There is one gateway for each organisation and environment. On-prem, the Gateway operatorA Kubernetes operator in the data plane. When it sees an APIGateway resource, it installs the gateway chart, which holds the controller and the runtime.See it in the glossary installs it when it sees an APIGateway resource. On Choreo Cloud, Choreo Labs’ own services create it.
The parts and their ports
On-prem, the gateway values that the Agent Manager chart hands to the operator give each part its numbers.
| Part | Port | Job |
|---|---|---|
| Controller, management REST API | 9090 | Manage the gateway. |
| Controller, xDS for the router | 18000 | Send listeners, routes and clusters to the router. |
| Controller, xDS for the policy engine | 18001 | Send policy chains and key hashes to the engine. |
| Router, HTTP and HTTPS | 22893 and 22894 | Receive requests. |
| Policy engine, admin | 9002 | Administration of the engine. |
xDSEnvoy's way of receiving listeners, routes and clusters while it runs. The gateway-controller serves xDS, so the router and policy engine update without a restart.See it in the glossary is Envoy’s way of receiving its configuration while it runs, so nothing has to restart when a route changes. Choreo Cloud’s gateway template uses 8080 and 8443 for the router instead.
Where the configuration comes from
The gateway does not make up its rules. They reach it by two routes, and both start in Agent Manager.
- An agent’s own route comes from the TraitAn optional extra that an OpenChoreo component type allows. The api-configuration trait, for example, adds an agent's route and policies on the API Platform Gateway.Analogy:Optional equipment fitted to an aircraft.See it in the glossary
api-configuration. When an agent is deployed, the trait creates a RestApi resource in the agent’s namespace, with the route and the policies that Agent Manager chose. The gateway operator finds the gateway that the resource’s label points at and hands the resource to that gateway’s controller on its management port, 9090. - LLM providers, LLM proxies, MCP proxies and A2A agents come from AMS. AMS writes an event, and the controller fetches the definition over REST.
The controller dials AMS
It opens a WebSocket to AMS’s internal server, with its registration token in the api-key header. If the line drops, it reconnects, waiting from 1 second up to 5 minutes.
It collects what it needs
When AMS reports a deployment, the controller fetches the definition of that LLM provider, proxy or A2A agent. It also fetches the lists of API key hashes. An agent’s route arrives from the gateway operator instead, as described above.
It feeds the router and the engine
Listeners, routes and clusters go to the router. Policy chains, route settings and API key hashes go to the policy engine. From then on the route exists on the gateway.
It keeps its state
The controller saves what it rendered in a small SQLite database on a 100Mi volume, so a restart does not lose it.
The policies themselves are compiled into the gateway when its image is built, from the gateway’s build file. AMS does not send code. It decides which policies a route uses. Each gateway also tells AMS which policies it has installed, and AMS keeps the latest list it received, so the console only offers the rules that the gateways report.
One request through the gate
A caller reaches the first gateway
The data plane’s ingress gateway, kgatewayThe Gateway API implementation that serves as OpenChoreo's ingress. The data plane's instance routes requests by host name and checks no credentials.See it in the glossary, routes by host name. It does not check credentials.
Everything is passed to APG
A patch added at deploy time points all of the route’s traffic at the gateway runtime. On-prem that is port 22893.
The router asks the policy engine
The router sends each request to the policy engine and waits for the answer. If the engine cannot answer, the request is not let through. The link is set to fail closed.
The policy chain runs
The engine looks up the Policy chainThe ordered list of policies that the gateway runs for one route. Request policies run in order, response policies in reverse, and a policy can end the request early.See it in the glossary for this route. It runs the request policies in order and the response policies in reverse. For an agent route, the browser access rules come first and then one key check or one token check. A policy can end the request early, for example with a 401, 403 or 429.
The agent is called
If everything passes, the router calls the agent’s Service, and the answer comes back the same way.
On-prem, an agent in the cluster is given the address of its environment’s gateway runtime Service, on port 22893, for its model calls and its trace uploads. It does not go out through the ingress and back.
In Choreo Cloud
Each organisation and environment still has its own gateway. Choreo Labs’ own services create it, the provisioner or platform-api’s bootstrap, and OpenChoreo deploys it to the data plane. In the gateway template of the organisation bootstrap, the controller keeps its state in Postgres instead of a file. Agents there reach the gateway on its public host name, not on the in-cluster runtime address.
Your turn
Under Try it, play flow F8 and stop at the step where the policy engine checks the request. What happens if it cannot answer? Then open the gateway diagram and click the router and the policy engine in turn. Which port does the router listen on? Finish with the matcher that pairs each part and port with its job.
Recap
- APG is two Deployments. The gateway-controller prepares the configuration. The gateway runtime holds the Envoy router and the policy engine.
- The controller dials AMS and receives definitions, from AMS and, for an agent’s own route, from the gateway operator. It feeds the router (port 18000) and the policy engine (port 18001). It keeps its state in a small SQLite database on-prem.
- The policies are compiled into the gateway’s image. AMS chooses which ones a route uses and keeps the latest list of installed policies that a gateway reported.
- The router asks the policy engine about each request, and fails closed if the engine cannot answer.
Wrap up
Recap
Tick each one when you could explain it to a colleague.
Finished?
Chapter complete. Every lesson in this chapter is done.
Progress cannot be saved in this browser, so it will be forgotten when you leave this page.
Quick check
Spotted something wrong or unclear in this lesson? Report an inaccuracy (opens GitHub in a new tab)