Guides

LLM usage and cost

Track token usage and spend by exporting agent telemetry to the gateway

The LLM Usage tab in Analytics shows how many tokens your coding agents consume and what they cost, broken down by model and user. It is powered by OpenTelemetry (OTel) data that the agents export to the gateway.

Setting it up is two steps: create an API key on the Discovery Sources page, then point Claude at the gateway's OTLP endpoint using that key.

1. Create a telemetry API key

  1. Open Discovery Sources — In the gateway, go to Discovery Sources in the sidebar.

  2. Create the key — Click Create API key, give it a recognizable name (for example, claude-code-mdm), and click Create.

  3. Copy the key — The full key (prefixed saai_ingest_) is shown only once. Copy it now — you won't be able to see it again. If you lose it, revoke the key and create a new one.

The dialog also shows the OTLP endpoint and a ready-to-paste configuration for each client. Both values below come straight from that dialog:

  • OTLP endpoint – https://<your-gateway-host>/api/v1/telemetry/claude
  • OTLP headers – Authorization=Bearer saai_ingest_…

You can manage existing keys from the same page and Revoke any key that should no longer be accepted.

2. Configure Claude to export telemetry

Both options send the same OTel data to the gateway. Use whichever client your team runs — you can set up both against the same key.

Claude Code (managed settings)

Distribute the gateway's OTel settings to your fleet through Claude Code's managed settings.json, deployed via MDM.

In the Claude admin console, go to Claude Code → Managed settings (settings.json), click Manage, and add the env block:

Claude Code product page in the admin console with the Managed settings (settings.json) row and Manage button
Claude Code → Managed settings (settings.json) → Manage
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://<your-gateway-host>/api/v1/telemetry/claude",
    "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer saai_ingest_…"
  }
}
Managed settings dialog showing the settings.json editor with the OTel env block pasted in
Paste the env block into the settings.json editor (your API key replaces saai_ingest_…)

Click Update settings. Managed settings override user and project settings and apply to Claude Code across the CLI, IDE, and Desktop app.

Claude Cowork

For Cowork, configure the same endpoint in the Claude admin console under Cowork → Monitoring (Team or Enterprise plan, app version 1.1.4173 or later):

FieldValue
OTLP endpointhttps://<your-gateway-host>/api/v1/telemetry/claude
OTLP protocolhttp/protobuf
OTLP headersAuthorization=Bearer saai_ingest_…
Cowork settings page in the admin console showing the Monitoring section with OTLP endpoint, protocol, and headers fields
Cowork → Monitoring — set the OTLP endpoint, protocol, and Authorization header

Cowork automatically adds the gateway host to its network egress allowlist when you save the endpoint. Start a new Cowork session for the change to take effect.

3. View LLM usage

Once agents are configured and have run at least once, open Enforcement Traffic and select the LLM Usage tab. You'll see:

  • Total Tokens and Total Cost (USD) for the selected period
  • Cost over time and token usage trends
  • Top users by cost and top models by cost

Use the time-range selector and the model and user filters to drill in. If the tab still reads "No LLM usage yet," the agents either haven't sent data yet or aren't configured — recheck the endpoint and Authorization header, and confirm telemetry is enabled.

On this page