Supported gateways
Choose your gateway for its metrics configuration and attribution instructions.Connect your gateway
Open Integrations, select your gateway, and name the connection. Choose its tenant and deployment location under Where it runs. Complete the settings for that location, then select Connect.Kubernetes cluster
Install the CostGraph operator and enable its AI gateway scraper in your Helm values.operatorPrometheus.scrapeTargets takes precedence over a discovered target.
Pod selector
Use a comma-separated list ofkey=value labels. Every term must match the
same pod. Select only the gateway’s data plane pods. Its control plane does not
expose the required token metrics.
The following command lists pod labels so you can build the selector.
llm.
Virtual machine
Install the CostGraph agent on the host. Select A virtual machine, choose the Instance, and confirm Metrics port. Only machines with a reporting agent appear in the instance list. The agent reads metrics from the host’s loopback address. The connection prefills these ports. Change the port to match your gateway’s configuration.
If the connection stays pending, check that its metrics endpoint responds.
For a vLLM server using the default port, run the following command on the host.
View gateway metrics
After the connection starts collecting, open its Metrics tab to chart requests, latency, tokens, and spend per hour for each model. CostGraph also alerts you when a connection stops delivering data. Refer to View gateway metrics for each chart, the gateways that report it, and how to resolve an empty chart.Attribute usage to your customers
Configure the customer identifier in your gateway’s metrics. CostGraph stores it as a sub-account so you can group usage and costs by customer. The Supported gateways table links to each gateway’s setup. For workload-level attribution, use thecostgraph.ai/sub-account annotation.
A customer label on a request takes precedence over this annotation. vLLM supports
workload-level attribution only.
Group usage by agent run
Include the sandbox’srun tag value in each request using your gateway’s
supported header or metadata field. CostGraph adds the model cost to that run
under AutoPilot > Sandboxes > Runs. The run value must match exactly.
Follow your gateway’s guide for the request configuration and
Group cost by run for sandbox setup.
How usage is priced
CostGraph selects a rate for each model and token type in the following order.- A rate selected by a
costgraph.ai/pricing-id.modellabel on the collected Kubernetes pods or their namespace. - A matching model catalog rate. This is a reference cost, which can differ from the cost of serving the model yourself.
- An amortized rate for a connected Kubernetes model server such as vLLM. CostGraph divides its serving namespace’s daily cost by the tokens collected through that connection that day. A proxy such as agentgateway does not use this fallback to price the model servers behind it.
Use your own model rates
To use a different price, register your input and output rates with Publish model prices. Use an API key withpricing:write. Each entry specifies the model,
token_bucket, and unit_price_per_mtok. Supply a rate for each token type you
want to price. The API returns an id for each entry.
For a model that isn’t in the CostGraph catalog, set the entry’s model to the
exact name your gateway reports. CostGraph prices that model’s usage at your
rates, without a pin.
For a Kubernetes connection serving one model, set
costgraph.ai/pricing-id.model on the gateway’s data plane pods to a returned ID.
Set the label in the pod template so replacement pods keep it. CostGraph uses the
selected model’s rates for each token type from the same registered host.
The pin applies to all model usage collected through that connection. Do not use
one pin to assign different prices to several models behind a shared gateway.
The dashboard does not provide a per-model rate editor for gateway connections.
After the next processing cycle, check the model’s quantity and cost in
Cost breakdown. For example, set rates of $1 per million input tokens and
$4 per million output tokens. One million input tokens and 250,000 output tokens
then cost $2. The table’s unit price blends the token types in the row.
These rates change CostGraph’s cost calculation. They do not change what your
model provider charges or configure customer invoicing. See
Pricing IDs for how to assign a rate.
Connection settings
Setmodel_map and attribution_spec in the API request when creating a connection.
Set model_map and tenant_map on an existing connection.
Model map
Usemodel_map to match a model identifier reported by your gateway to a
CostGraph catalog model. It changes which model CostGraph looks up. It does not
set an input or output price. To change those prices, see
Use your own model rates.
For example, the following map identifies gpt4o-prod as openai/gpt-4o.
CostGraph then looks for a rate for that model.
Tenant map
Usetenant_map to rename a reported sub-account. This example displays
acct-7 as Acme.
Attribution spec
Useattribution_spec to select labels or fields for customer and other cost
dimensions. This example reads customer_id into the sub-account and retains
team as a cost extension.
source to prom_label for scraped metrics, focus_field for pushed rows,
or static for a fixed value in key. Add "transform": "sha256" to hash a value
before storage. A rule with "required": true rejects a batch if its key is absent.
Without a spec, the connection reads costgraph_sub_account from metrics or
SubAccountId from pushed rows into the sub-account.