Skip to main content
agentgateway reports GenAI token usage from its data plane. See the upstream LLM observability reference.

What CostGraph scrapes

Token metrics come from the per-Gateway data plane, not the control plane, and those pods live in whichever namespace you created the Gateway in. An agentgateway connection must name the namespace and the pod label selector, or nothing can ever be scraped.
Read the labels off the running data plane pods and narrow the selector until it matches them and nothing else:

How the metric maps

agentgateway_gen_ai_client_token_usage becomes costgraph_gen_ai_usage_total: The unit is always tokens.

Attribute usage to your customers

Add a metric attribute computed from the request. On Kubernetes this goes in an AgentgatewayPolicy. The value is a CEL expression, so the identifier can come from a header, a JWT claim, or anything else in the request.
A policy applies only where it is targeted, so it needs targetRefs or targetSelectors naming your Gateway. It must also live in that Gateway’s namespace, because a policy cannot reach across namespaces. If a policy already targets the Gateway, add the attributes block to that one instead of creating a second.

AI gateways

Connecting, pricing, and sending usage yourself.