A team lead finds one developer's Claude Code spend tripled in a week; how would you set up per-user cost visibility and caps for the whole team?
answer
- who pays decides the controls
- seats, workspaces, cloud budgets
- one view across every setup
- managed settings, not the repository
- cost.usage and token.usage types
basics
~20 sMatch caps to how the team pays: seat allowances plus usage-credit spend limits on Teams or Enterprise, workspace spend limits on the Console, cloud budgets on Bedrock, Agent Platform or Foundry. For per-user visibility everywhere, push OpenTelemetry export through managed settings.
solid answer
~40 sFirst establish how each developer is billed, because metering follows sign-in: Teams and Enterprise draw on a per-seat allowance, then usage credits with organization, group or member spend limits; Console usage lands in the auto-created Claude Code workspace, where you set workspace spend and rate limits; Bedrock, Agent Platform and Foundry bill your cloud account and need cloud budgets. Then add OpenTelemetry, the one view that works on every setup: `CLAUDE_CODE_ENABLE_TELEMETRY=1` plus the `OTEL_*` exporter variables in the managed settings `env` block — repositories cannot set them. `claude_code.cost.usage` and `claude_code.token.usage` (split into input, output, `cacheRead`, `cacheCreation`) by user, model and `query_source` show whether the spike is long uncleared sessions, Opus by default, cache churn or subagents. Costs are list-price estimates unless `modelPricing` is set.
code
json · 10 lines{
"env": {
"CLAUDE_CODE_ENABLE_TELEMETRY": "1",
"OTEL_METRICS_EXPORTER": "otlp",
"OTEL_LOGS_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector.example.com:4317",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer example-token"
}
}go deeper
Recall that how a developer signs in decides where spend shows up, and that OpenTelemetry export starts with CLAUDE_CODE_ENABLE_TELEMETRY=1.
Explain which cap applies per setup — seat allowance and usage-credit limits, Console workspace limits, cloud budgets — and which OpenTelemetry metrics carry cost and tokens.
Show the rollout details: managed settings because repositories cannot set exporter variables, a pinned collector endpoint, token types and query_source for diagnosis, and list-price estimates corrected by modelPricing.
Own the trade-offs: seats versus per-token billing by usage shape, hard caps where the bill lands versus visibility through telemetry, privacy opt-ins, and a pilot baseline before tightening limits.
## Start from how the team pays There is no single Claude Code spend dashboard, because **where spend is metered depends on how each developer signs in**. If an organization mixes sign-in methods, each developer is metered by the one they used. So the first governance decision is to know, per developer, which of these applies: | Setup | See spend | Cap spend | Per-user numbers | | - | - | - | - | | Claude for Teams or Enterprise | Spend report in org analytics | Seat allowance, then usage-credit spend limits in admin settings | Spend report CSV; Enterprise Analytics API on Enterprise | | Claude Console (API) | Console usage page | Workspace spend limits | Console dashboard; Claude Code Analytics API | | Bedrock, Google Cloud's Agent Platform, Foundry | Your cloud billing console | Your cloud's budget controls | OpenTelemetry or an LLM gateway | Each row has a different natural ceiling: - **Teams and Enterprise** — the per-seat allowance (a rolling five-hour window and a weekly window, shared with Claude chat and Cowork) is the default cap. Usage past it needs **usage credits**, with spend limits at organization, group or member level. Inside the allowance, usage is not metered in dollars at all. - **Console** — authenticating Claude Code creates a dedicated "Claude Code" workspace. Put a **workspace spend limit** on it, and a **workspace rate limit** if Claude Code traffic must not starve other production workloads sharing the organization's API limits. - **Cloud providers** — Claude Code does not send metrics from your cloud back to Anthropic, so Anthropic's analytics dashboards and the Claude Code Analytics API do not see it. Budgets live in your cloud account. ## OpenTelemetry: the one view that works everywhere **OpenTelemetry export works on every setup** and is the only option that streams per-user token and cost metrics into your own observability stack in near real time. It is opt-in: - `CLAUDE_CODE_ENABLE_TELEMETRY=1` turns collection on (required); - `OTEL_METRICS_EXPORTER` and `OTEL_LOGS_EXPORTER` choose exporters (`otlp`, `prometheus` for metrics, `console`, `none`); - `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` point at your collector. **Roll it out through managed settings**, in their `env` block. Claude Code ignores these variables in a repository's `.claude/settings.json` and `.claude/settings.local.json`, so a checked-out repository cannot turn telemetry on, redirect it or capture content. When managed settings set `OTEL_EXPORTER_OTLP_ENDPOINT`, Claude Code also removes developer-set per-signal endpoints, so nobody can point one signal at a different collector. ## What the metrics tell you | Metric or attribute | Use | | - | - | | `claude_code.cost.usage` (USD) | Spend per user, team, model, session | | `claude_code.token.usage` with `type` = `input`, `output`, `cacheRead`, `cacheCreation` | Whether spend is fresh input or cache churn | | `query_source` = `main`, `subagent`, `auxiliary` | How much comes from delegated work | | `model`, `effort`, `speed` | Expensive model, effort or fast-mode habits | | `skill.name`, `plugin.name`, `agent.name` | Which extension drives usage | | `user.email`, `user.account_uuid`, `session.id` | Who and which session | Cost metrics are **approximations** computed at list price; the provider's billing data is authoritative. If the organization pays contracted rates, set the `modelPricing` managed setting so `/usage`, the status line and telemetry report at those rates. Privacy defaults matter when you present this to developers: prompt text, response text and tool arguments are **not** exported unless you opt in (`OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_ASSISTANT_RESPONSES`, `OTEL_LOG_TOOL_DETAILS`), and data goes only to the endpoint you configure. ## Diagnosing the tripled week With telemetry in place, the usual causes become visible rather than argued about: 1. **Long sessions never cleared** — large `cacheRead` volumes on every turn, because the whole conversation is re-sent each time. 2. **Opus as the default** — the `model` split. 3. **Cache churn** — high `cacheCreation`: frequent model switches, idling past the TTL on API billing. 4. **Delegation** — a rising `subagent` share, or experimental agent teams, which the docs put at roughly seven times a standard session when teammates run in plan mode. 5. **Unattended work** — scheduled tasks and loops firing on an idle session with full context each time. On a subscription, the developer can see the same story locally in the `/usage` breakdown, which flags behaviours above 10% of recent usage. ## The judgment calls - **Cap where the bill lands.** Seat allowances, usage-credit spend limits and workspace spend limits stop requests; cloud budget controls act as your cloud account configures them; telemetry is visibility, not enforcement. - **Choose the billing model by usage shape.** Steady interactive use often fits seats; spiky automation often fits per-token billing with workspace limits. - **Bound automation separately.** Headless runs can carry `--max-budget-usd`, which stops a print-mode run at a dollar cap. - **Measure before tightening.** The docs suggest a pilot group to set a baseline before wider rollout.
- Why not ask each team to enable telemetry in its repository's `.claude/settings.json`?Claude Code ignores the OpenTelemetry exporter variables in project and local settings, so a repository cannot turn telemetry on, choose its destination or capture content; it can only switch a signal off by setting its exporter to `none`. Set them in managed settings, or have developers set them in their shell or `~/.claude/settings.json`.
- Your OpenTelemetry cost totals are lower than the invoice. Name two reasons.The cost metric is an approximation at list price, so contracted rates or adjustments differ until `modelPricing` is set in managed settings. And telemetry covers only machines that export it: a developer who launched without the managed settings, or usage on claude.ai rather than Claude Code, never reaches your collector.
- Turn on telemetry in the repository's .claude/settings.json so every clone reports.
- OpenTelemetry cost figures are exact and match the invoice.
- Claude Code's OpenTelemetry export sends prompt text to your collector by default.
- The Claude Code Analytics API covers usage billed through Bedrock.
- Telemetry alerts are enough to cap a developer's spend.