AI Gateway flow diagrams

Nine diagrams covering the traffic path, the two-key model, three provider cases, one client case, attribution and billing, the per-request pipeline, and how an agent's identity reaches the gateway. Review here, then we wire the approved ones into the deployment guide.
How to read this set

Each diagram is layered on purpose. The boxes and arrows carry the conceptual story that an architect or an exec can follow in one pass. The monospace insets carry the actual headers, environment variables, and field names, so the same page also works as a build reference on a deployment call. Nothing is duplicated between the two layers.

Sources are .drawio, exports are .svg (25 to 50 KB each, light mode pinned, no raster fallback). Both sit next to this page in docs/guides/ai-gateway/diagrams/, so every diagram below is editable. Open a .drawio file in diagrams.net, edit, then re-export with clean-svg.py in the same folder.

1How the API key gets into the app call

Answers: why the keys are essential, and how the credential is actually swapped.

Source aigw-key-flow.drawio · Export aigw-key-flow.svg
Two swim lanes. The data plane shows an application sending a request to the AI Gateway and on to an LLM provider, with the on-the-wire headers before and after the gateway. The control plane shows a secrets manager feeding the provider key into a Strata Cloud Manager integration, which issues separate gateway API keys to the app team.
Two keys are in play. The application only ever holds the gateway key; the provider key never leaves Strata Cloud Manager.

The whole diagram exists to make step 4 land: the gateway strips the caller's key and attaches the provider credential. That single swap is what makes every downstream control possible, because the provider will only ever see one caller.

2Getting the gateway inline

Answers: how the gateway gets inline, and what elements are required.

Source aigw-getting-inline.drawio · Export aigw-getting-inline.svg
A before lane showing an app calling the provider directly, and an after lane showing the same app calling the AI Gateway. Below them, a five-row table listing the gateway base URL, gateway API key, integration slug, model reference, and provider header, with an example value, where to find it in Strata Cloud Manager, and the failure mode for each.
No application logic changes. Three values move the traffic: the base URL, the credential, and the slug that names which integration should serve the call.

The table is the part a customer will screenshot. Every row has a failure column, because most cutover problems are one of these five values being subtly wrong rather than anything about the gateway itself.

The point the bottom-right box exists to make

The gateway is opt-in per application. Nothing forces traffic through it by routing, DNS, or a proxy setting. An app that still points at the provider endpoint keeps working and stays completely invisible to the gateway, which means coverage is an application inventory exercise, not a deployment task.

3AI Gateway fronting Amazon Bedrock

The requested Bedrock case, built on standard Amazon Bedrock with an IAM credential.

Source aigw-bedrock.drawio · Export aigw-bedrock.svg
An application with no AWS credential calls the AI Gateway, which translates and SigV4-signs the call into a customer AWS account containing the Bedrock runtime endpoint, the provisioned foundation models, and a least-privilege IAM identity. Callouts cover the two billing meters, where the prompt physically travels, and the credential, region, and PrivateLink detail confirmed in the documentation.
The app holds no AWS credential. The gateway signs the Bedrock call with an IAM identity that only it holds, in a region pinned at configuration time.

4AI Gateway fronting OpenAI

The same structure as Bedrock, plus the scope distinction that trips up most OpenAI conversations.

Source aigw-openai.drawio · Export aigw-openai.svg
An application with no OpenAI key calls the AI Gateway, which strips the gateway key and attaches the organization's OpenAI key before calling the OpenAI API endpoint. Callouts cover the Strata Cloud Manager integration fields, the distinction between the OpenAI API and the ChatGPT app, the two billing meters, and the integration fields and endpoint coverage confirmed in the documentation.
The app holds no sk-proj- key. One OpenAI key lives in the integration record, and the OpenAI usage dashboard collapses to a single caller as a result.
The headline finding — the gateway fronts the OpenAI API, not the ChatGPT app

This is the one to raise on the first call. ChatGPT in a browser, the desktop app, and the mobile app have no base URL setting. There is nothing to point at a gateway, so that traffic never reaches Observability and no budget, allowlist, or guardrail touches it.

When a customer says "we use ChatGPT", establish which one they mean. Code calling api.openai.com from an SDK, an agent framework, or a CI job is exactly what the gateway covers. People typing into chatgpt.com is a network egress policy, a CASB or SASE control, or ChatGPT Enterprise's own admin and compliance tooling.

The same split applies to Claude.ai against the Anthropic API, and to a Copilot surface against the Azure endpoint behind it. Naming the split on the first call avoids a scope argument at cutover, because "we are governing our AI usage" turns out to mean two different projects.

5AI Gateway fronting Azure AI Foundry

The Azure case, where the naming discipline matters more than the wiring.

Source aigw-azure-foundry.drawio · Export aigw-azure-foundry.svg
An application with no Azure credential calls the AI Gateway, which rewrites the call to a Foundry resource endpoint, a named model deployment, and a pinned API version inside the customer's Azure subscription, authenticating with either a resource key or an Entra identity. Callouts cover the two catalog entries, deployment naming, the two billing meters, and the three authentication types the integration form accepts.
The app names a deployment, not a model. The gateway holds the endpoint, the API version, and either the resource key or an Entra identity with a role on the resource.

This diagram carried the most unconfirmed detail of the eight when it was drafted, because the deployment guide records the Azure integration form's exact field set as still to be captured. The Azure Foundry integration page in the documentation mirror answers all of it, and the detail box now states the field set rather than asking about it.

6Routing Claude Code through the gateway

The client-side half of the picture, and the only path in this set that has been run end to end.

Source aigw-claude-code.drawio · Export aigw-claude-code.svg
A developer workstation sets three environment variables and sends a request to the AI Gateway, which strips the gateway key, attaches the Anthropic key, and calls the Anthropic API. The on-the-wire headers are shown before and after. Below, a four-column table describing each variable, and three callouts covering validation order, where the values live, and two rollout decisions.
Three environment variables, no reinstall and no proxy. The values here are observed rather than assumed, because this is the path the deployment guide was validated against.

The other diagrams face a provider. This one faces the client, which is where cutover actually fails. The four-column table exists because each variable has a distinct failure mode, and the third one is the one everybody forgets.

Why this one gets a green validation box instead of a red verify box

The wiring in this diagram comes from a section of the deployment guide that was run live and screenshotted, so the values, the error strings, and the precedence behaviour are observed rather than inferred. The green callout gives the four proof steps in the order that isolates the fault fastest: echo the variable, curl the gateway, run /status, then look for the row in Observability.

The two decisions to make before rolling this out

First, where the key is allowed to be written. Never in a project's .claude/settings.json, because that file is committed and shared with everyone who clones the repository. Use the user-level ~/.claude/settings.json, or the gitignored .claude/settings.local.json for a single project.

Second, one key per developer or one for the team. A shared key makes Observability show one caller for the whole team, and revoking it after a leaver takes everyone offline at once. A key per developer gives per-person cost and clean revocation, at the price of issuing and tracking them. Either way, put the person or team in the key's metadata tags at issue time, because that is the only thing the logs can group by later.

Claude Code is only the worked example. Any client that accepts a base URL override follows the same pattern with no application logic change, which is the point the footer bar makes.

7Attribution and billing

Answers: how billing is defined, what data is captured, and where group information comes from.

Source aigw-attribution-billing.drawio · Export aigw-attribution-billing.svg
Three columns. Left, a five-step attribution chain from Organization down through Workspace, Integration, the gateway API key, and the request. Centre, the fields captured in the prompt log and the event log, and the two separate money flows. Right, a panel explaining that group information is metadata you define rather than anything sourced from an identity provider.
Every cost figure and every group breakdown traces back to one thing: the gateway API key the request arrived with, and the metadata attached to that key.
The headline finding — group information is not identity-derived

This is the question that prompted the diagram, and the answer is counter-intuitive enough to be worth stating plainly. SSO and Cloud Identity Engine govern who can log into Strata Cloud Manager. They do not tag traffic, and there is no directory group carried on the request.

Groups are JSON metadata tags you attach to each gateway API key. Those tags flow into the logs, a budget or rate policy in Policies & Profiles matches on a Condition Key with includes and excludes lists, and Group by Key then applies the cap per value of that key rather than to the matched set as a whole.

The consequence: the metadata schema is the chargeback model. It has to be agreed before the first key is issued, because budget limits never apply retroactively and keys already in production carry their old tags until they are reissued.

Narrowed by diagram 9

The statement above holds for groups, and it is still the right answer to the chargeback question. Two things it understates are covered in diagram 9. Cloud Identity Engine does more than gate console login: through Directory Sync it decides which directory users exist as AI Gateway users in which workspace, and a User API key can only be issued against someone that sync has already provisioned. And a request authenticated with a JWT does carry a user identity, read from the token's own claims. What never arrives is a directory group the gateway could policy on, which is why metadata remains the grouping mechanism either way.

8What the gateway does to a single request

The per-request pipeline, including every place a call can stop and where the record lands.

Source aigw-request-lifecycle.drawio · Export aigw-request-lifecycle.svg
A horizontal pipeline of six checks: authenticate, resolve the slug, model allowlist, guardrails, rate limit, and budget. Each shows the error it stops with. Then a credential swap, the provider call, and a meter and log step that fans out to four logging destinations.
Six checks, then a credential swap, then the meter. Each check is a place the request can stop, and each stop is a control the customer asked for.

This is the troubleshooting diagram. Each gate shows the error a caller actually receives, so a support conversation can start with the error string and land on the right gate immediately.

What this pipeline does not do

A guardrail that exists in the catalogue does nothing until it is attached. Every check in step 4 runs only when its guardrail ID is listed in a config's before_request_hooks or after_request_hooks, and a guardrail set to async=true observes and logs without blocking, returning 246 rather than 446. Enabling a guardrail is not the same as enforcing it on a route.

9How an agent's identity reaches the gateway

Answers: how an agent running against the gateway is authenticated, what identity the gateway ends up attributing the call to, and which part of that Cloud Identity Engine and Azure Entra ID each supply.

Source aigw-agent-identity.drawio · Export aigw-agent-identity.svg
Three horizontal bands. The control plane band runs Entra ID into Cloud Identity Engine, Directory Sync, a one-to-one group to workspace mapping, and the resulting workspace member list, labelled as running on a schedule. The data plane band runs an agent to Entra ID for a token, then into the AI Gateway, which validates the signature against the JWKS, resolves the organization and workspace, checks the route scope, and attributes the request. The egress band shows the gateway swapping in its own Azure credential to reach Azure AI Foundry. A callout between the first two bands explains that the email claim on the token has to string match an AI Gateway user in the target workspace. Side panels cover why there is no User-ID here, the three separate jobs Entra ID performs, what each credential type attributes to, and which credential an agent should use.
Entra ID appears three times in this picture and means something different each time: the directory behind Cloud Identity Engine, the issuer of the agent's token, and the credential the gateway uses to reach Azure.
The headline finding — there is no User-ID in the AI Gateway

The question as usually asked assumes a PAN-OS mechanism that does not exist here. User-ID is a firewall construct: the firewall learns an IP-to-user mapping out of band, from a domain controller or a User-ID agent, and security policy then matches on the user it found. The AI Gateway has none of that. There is no IP-to-user mapping, no User-ID agent, and no directory group travelling with the request.

Identity arrives inside the request, as the credential itself. So the question that does have an answer is which credential the agent presents, and what identity that credential carries. The diagram is built around that reframing, which is why the red panel sits first.

The three jobs Entra ID does are on three different clocks, and conflating them is most of the confusion. They are also configured in three different places, so a customer can have one working and assume the others follow.

All three can point at the same Entra tenant. They are still three separate configurations, and the third one works perfectly well when the first two are absent.

The one string that has to match

Per-user attribution turns on a plain string comparison. When the email on the agent's token matches an AI Gateway user in the target workspace, the request is attributed to that person and inherits their workspace role. When it does not match, the request falls back to a generic workspace service key and the per-user attribution is silently lost, with no error on the call.

That makes the User Identity Attribute chosen in Directory Sync, UPN or Mail, a decision with teeth. It has to produce the same value as the email claim Entra puts in the token. Choose Mail wherever the UPN is a user@tenant.onmicrosoft.com form and the real address is not.

On the data plane, the gateway reads user identity from the claims in a fixed precedence order: email_id, then sub, then uid. Tokens must be RS256 with a kid that resolves in the configured JWKS and an exp that is present and in the future. An HS256 token is rejected with an error that reads as a bad API key rather than a bad algorithm, which sends people looking at the wrong thing.

Mode A and Mode B, and why Entra is the Mode B case

Mode A is for when you control the token issuer and can add the gateway's own portkey_* claims to it. Mode B takes a stock IdP token and resolves the organization, the workspace, and the scopes on the gateway instead. Entra is explicitly the Mode B case, because an organization generally cannot add gateway-specific claims to a corporate token for one application. Where scopes cannot be issued in Entra, JWT_LOCAL_AUTH_DEFAULT_SCOPES supplies them.

Validation location also varies. On AI Gateway Cloud the management plane validates the token. A hybrid or air-gapped gateway on 2.5.0 or later can validate locally with JWT_ENABLED=ON, which keeps authentication working when the management plane is unreachable.

Gaps worth raising with the customer

Twelve points that a customer conversation tends to skip past. All twelve changed the diagrams and are baked into the artwork rather than left as speaker notes.

GapWhy it mattersWhere it appears
The gateway is opt-inNothing forces traffic through it. An app still pointing at the provider endpoint works fine and is invisible. Coverage has to be closed with egress policy or by revoking direct provider keys.Diagram 2, bottom right; diagram 8, bottom right
Consumer AI apps cannot be fronted at allChatGPT, Claude.ai, and other browser or desktop apps have no base URL setting, so they can never route through the gateway. If the customer's mental model of "our AI usage" is the app rather than the API, half the programme is a CASB or SASE conversation, not a gateway one.Diagram 4, the red headline box
Two separate money flowsFlex credits and provider spend are different numbers in different consoles. Finance will reconcile them and find they do not match, because they are not meant to.Diagrams 3, 4, and 5; diagram 7
Provisioned capacity breaks cost reconciliation entirelyWith Azure PTU, or any committed capacity arrangement, provider spend is fixed and does not track tokens. Gateway cost figures are then an allocation tool only, and presenting them as a bill forecast will lose credibility with Finance.Diagram 5, two meters callout
Provider naming discipline is a prerequisiteAzure deployment names are typed by hand at deploy time and are what the app, the allowlist, and every log row carry. Agreeing a convention before provisioning costs nothing; retrofitting one breaks every caller.Diagram 5, deployment name callout
Metadata schema is the chargeback modelIt must be agreed before the first key is issued. Budget limits are never retroactive and issued keys carry their old tags.Diagram 7, right panel and bottom callout; diagram 6, second rollout decision
Limits cannot be edited once setBudget and rate limits cannot be changed by any organization member after creation. Getting them wrong means recreating the object.Diagram 7, bottom right
Data residency under SaaSPrompts leave the customer environment before reaching the provider, even when the model sits in the customer's own AWS account or Azure subscription. This is the argument for Hybrid, and it should surface in design rather than at cutover.Diagram 3, "Where the prompt physically goes"
An unattached guardrail enforces nothingPII detection and content moderation are Pro guardrails on the gateway, so the capability is there. It only takes effect once the guardrail ID is attached to a config's request hooks, and an async=true guardrail logs without blocking. A customer who enables one in the catalogue and assumes it is live will find nothing was ever stopped.Diagram 8, step 4 and bottom left
Per-user attribution needs an application changeA shared application key attributes to the application. Splitting it per end user means sending x-portkey-metadata with its reserved _user key on every request, which the application has to do. For developer tooling this becomes a one-key-per-developer decision with real revocation consequences.Diagram 7, bottom centre; diagram 6, red callout
Agent identity hangs on one string comparisonThe email claim on an agent's JWT has to match an AI Gateway user in the target workspace, or the call quietly attributes to a generic workspace service key instead of a person. The UPN or Mail choice in Directory Sync is what decides whether those two strings agree, and a user whose chosen attribute is empty is skipped during sync with no error anywhere.Diagram 9, the amber join callout and pitfalls 4 and 5
Streaming calls log zero cost by defaultWith stream: true the provider returns no usage data, so tokens and cost record as zero and budget enforcement never sees the spend. The application has to send stream_options: {include_usage: true}. This affects every OpenAI-compatible provider, Azure OpenAI included.Diagram 4, confirmed-detail box

Verification against the documentation mirror

Why the diagrams originally carried open questions

These diagrams were drafted on 17 September 2026 with external research unavailable: WebSearch was blocked by an organization policy on this account, WebFetch was not available, and outbound curl was denied. Every provider-specific claim was grounded in repository material instead, and anything that could not be grounded that way was called out on the diagram rather than asserted.

The 627-page Portkey documentation mirror landed in pan-docs-reference/docs/portkey/ on 25 September 2026, eight days later. Almost every open question is answerable from it, so the diagrams were re-reviewed against it and the caveat boxes were replaced with the answers. What follows records what was checked, so a reviewer can attack the sourcing rather than the artwork.

Bedrock, on diagram 3 — all four resolved

OpenAI, on diagram 4 — three resolved, one still open

Azure, on diagram 5 — all resolved

Every answer here comes from integrations/llms/azure-foundry.md, except the role, which comes from the AKS hybrid page.

Corrected, on diagrams 7 and 8

Agent identity, on diagram 9 — drawn entirely from the mirror

This diagram was drafted after the mirror landed, so every box on it has a source rather than an assumption behind it.

Still unverified

Suggested next step

If these work, the natural placement in ai-gateway-deployment.html is one diagram per phase rather than a gallery:

DiagramPlacement
1. How the API key gets into the app callPhase 1 overview, or the concepts section, wherever the two-key model is first introduced
2. Getting the gateway inlineThe client wiring phase, immediately above the environment variable block
3. Fronting Amazon BedrockThe integration phase, inside the Bedrock tab
4. Fronting OpenAIThe integration phase, inside the OpenAI tab. The ChatGPT scope box may also be worth lifting into the guide's opening scope section, since it reframes the whole engagement.
5. Fronting Azure AI FoundryThe integration phase, inside the Azure tab, next to the existing TODO(provider-azure-openai) marker
6. Routing Claude Code through the gatewayThe Claude Code section, above the three exports. The four-column table could replace prose the guide currently carries.
7. Attribution and billingPhase 5, above the Policies & Profiles walkthrough
8. Single request lifecycleThe troubleshooting or reference section at the end
9. How an agent's identity reaches the gatewayPhase 5, immediately before diagram 7, since it answers where the identity on a request came from and diagram 7 then answers what is done with it. The red no-User-ID panel is also the right thing to put in front of a PAN-OS audience in the opening concepts section.

Wiring them in is deliberately not part of this change. The guide itself is untouched, so this page can be reviewed, argued with, or rejected without anything to unpick. If the set is approved, the follow-up is lazy-loaded img tags with italic captions inside the relevant collapsible bodies of ai-gateway-deployment.html.

↑