MusterMuster Docs

Cost Aggregation

Track LLM and cloud infrastructure spend per agent, with multi-currency rollups.

Muster captures two independent cost streams and unifies them at the dashboard layer:

  1. LLM tracing costs — derived from token counts on every generation observation, multiplied by configured model pricing.
  2. Cloud infrastructure costs — fetched from AWS Cost Explorer per cloud connection (Bedrock, SageMaker, etc.).

Both streams roll up daily and feed the same UI, so a single agent page shows model spend and infra spend side by side.

How LLM costs flow

trace observation
   └── usage.input + usage.output (token counts)
         × MusterModelPricing (per-1k input/output rates)
         = per-observation cost
              ↓ hourly costAggregation worker
        MusterAgentCostDaily (rolled up by trace name + date)

Token-level costs flow automatically as soon as two conditions are true:

  • The observation has token counts (usage.input and usage.output) — most SDKs populate these by default.
  • The model has pricing configured in MusterModelPricing (provider, model, inputPer1kUsd, outputPer1kUsd, effectiveFrom).

How cloud costs flow

A separate daily worker (cloudCostAggregation) hits AWS Cost Explorer for every agent linked to a cloud connection. Costs are stored per AWS service in MusterAgentCloudCostDaily. The Cost Explorer API itself charges per call, so the worker batches per-connection to keep that bill small.

To turn it on for an agent:

  1. Set MusterAgent.cloudConnectionId to a configured cloud connection.
  2. Set MusterAgent.cloudService to the AWS service ID (e.g. AmazonBedrock, AmazonSageMaker).
  3. Confirm the cloud connection's IAM role has ce:GetCostAndUsage.

Multi-currency

The exchange-rates worker fetches USD conversion rates daily for the following currencies: EUR, GBP, MYR, IDR, SGD, AUD, CHF, SEK, NOK, DKK (plus USD as base). Sources: ECB, Bank Negara Malaysia, Bank Indonesia. Rates land in MusterExchangeRate.

The cost dashboard accepts a currency parameter — pick one and every USD figure converts on the fly using the latest rate.

What you see in the UI

The musterCostsRouter exposes:

  • summary() — 30-day organization-wide overview: total spend, daily trend, token totals, top agents.
  • byAgent() — per-agent breakdown: LLM cost, cloud cost, combined, trend over the selected window.

These power the Cost Dashboard page, the trial banner ("you've used $X this period"), and the Weekly Report email.

Wire-up checklist

  • Traces include token counts (default on all Langfuse SDKs).
  • Every model used has a row in MusterModelPricing. Without it, LLM cost will be zero — Muster won't guess.
  • For cloud spend: cloud connection exists, IAM role has Cost Explorer permission, agent linked via cloudConnectionId.
  • Pick a default display currency in your project settings.