Find your usage in CostGraph
Open Cost breakdown and select Overview. Choose the tenant you connected and a date range that includes your gateway’s traffic. Group by Provider and findagentgateway in the table.
CostGraph processes gateway usage hourly. Allow up to an hour after it starts
collecting token usage for the aggregate to appear. A successful scrape means
the collector reached the metrics endpoint. It does not confirm that token usage
has been aggregated or priced.
The table shows the following results. Use Columns to show any hidden columns.
The following screenshot shows the
agentgateway row with model usage and
three customer sub-accounts.
You do not need to enter prices for models that match CostGraph’s pricing catalog.
If no rate resolves, CostGraph retains the token quantity with zero cost. Turn on
Columns > Show zero cost to include these rows. Zero cost does not mean the
model is free. Refer to Check model pricing to resolve a
missing rate.
What CostGraph scrapes
Follow Connect an AI gateway to connect your deployment. For Kubernetes, enable the AI gateway scraper in the CostGraph operator before connecting. Use the namespace and labels of the pods serving your Gateway. The control plane does not expose the token usage that CostGraph needs. Check the data plane pods before entering your connection’s namespace and pod selector. Replacemy-gateway-namespace with your Gateway’s namespace.
Send requests through the gateway after collection starts. CostGraph measures
token increases between samples, so a reachable endpoint without new token usage
does not produce a usage record.
Attribute usage to your customers
Add acustomer metric attribute to your AgentgatewayPolicy. The following
example reads the customer identifier from the x-costgraph-customer-id request
header. Requests with the value acme appear under the acme sub-account in
CostGraph after processing.
Use your Gateway’s name and namespace in the policy. If a policy already targets
that Gateway, add the metric attribute to it.
customer="acme" when you send that value. Without a customer
label, CostGraph shows gateway usage without the customer breakdown.
Group usage by agent run
Add arun attribute alongside customer in the same policy. Set the
x-costgraph-run-id request header to the run tag on the run’s sandboxes.
The run’s model cost then appears alongside its sandbox cost in
AutoPilot > Sandboxes > Runs.
The following fragment shows both attributes.
Check missing usage
If no usage appears after an hour, check the dashboard filters, source metrics, and connection status in that order.Check the dashboard view
Select the connection’s tenant and a date range that includes recent requests. Clear filters that exclude agentgateway and enable Columns > Show zero cost. If token quantities appear with zero cost, continue to Check model pricing.Check the token metrics
If you scrape agentgateway into Prometheus, run the following query there to see token increases over the last 15 minutes, grouped by model and token type. Add a namespace or pod filter if your Prometheus instance collects several gateways._sum series counts tokens, while _count counts
observations. Positive results confirm that your Prometheus instance has sampled
token usage. They do not confirm delivery to CostGraph.
To inspect the gateway directly, forward its metrics port. Replace the namespace
and pod name with values from your deployment.
http://localhost:15020/metrics.
gen_ai_response_model and a gen_ai_token_type such as
input or output. If no series appears, send a model request through this
Gateway and check again. Refer to agentgateway’s
Metrics and logs
for upstream diagnostics.
If the source metrics increase but CostGraph still shows no usage, open the
connection in Integrations and check its last report and any error. For
Kubernetes, confirm that its namespace and selector match the pods you inspected
and that the operator’s AI gateway scraper is enabled.
Check model pricing
CostGraph can price a recognized model from its catalog even when you have not configured pricing in agentgateway. If the connection reports unpriced models, compare the reported model identifier with the catalog entry. Use a model map when your gateway reports an alias. To use a different input or output price, follow Use your own model rates. That section covers the pricing ID for a single-model Kubernetes connection and its limits for shared gateways. Check the cost again after the next processing cycle. If usage is still missing, share the connection name, time of the requests, model identifier, and connection error with support. Remove credentials and customer identifiers from diagnostic output.How the metric maps
CostGraph converts theagentgateway_gen_ai_client_token_usage histogram’s token
sum into costgraph_gen_ai_usage_total.
The unit is tokens. The following labels connect usage to its model, customer,
and run.
