> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Total LLM cost preset shows no data

export const plans_0 = "Any"

export const deployments_0 = "Any"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case - Explain why Monitor's Total LLM cost preset can show no data and how to fix it by logging metadata.model on token-reporting spans or using sum(estimated_cost()) as a workaround"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## Summary

The Total LLM cost preset chart in Monitor can show no data if the token-reporting spans are missing a recognized `metadata.model` or LLM token metrics, even when traces include `metrics.estimated_cost`.

The preset prices spans from token metrics plus a recognized `metadata.model` on the same span. If you log costs directly in `metrics.estimated_cost`, you can use a custom chart with `sum(estimated_cost())`.

## What is happening

The preset derives cost from token metrics and `metadata.model` using Braintrust’s pricing registry. It will ignore spans when the model is null, missing, or unrecognized, even if `metrics.estimated_cost` is present.

For a span to contribute to the preset cost calculation, it must include:

* `span_attributes.type = 'llm'`.
* `metrics.prompt_tokens` or `metrics.completion_tokens` (or both).
* `metadata.model` set to a model Braintrust can price.

`metadata.model` should be on the spans that contain the token metrics. It does not need to be on the root span unless the root span also reports the token metrics. Preset charts sum cost per span (not per trace) and automatically exclude internal scorer spans.

## Fix or suggestion

### Option 1: Log model on token-reporting spans

Add `metadata.model` to the LLM spans that record token usage (typically child LLM call spans).

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
span_attributes.type: llm
metrics.prompt_tokens: 1000
metrics.completion_tokens: 250
metadata.model: gpt-4o-mini
```

Avoid logging the same token metrics and model on both root and child spans, since preset charts sum per span and can double count.

### Option 2: Use a custom chart

If you already log explicit cost in `metrics.estimated_cost`, you can create a custom Monitor chart with:

```sql theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sum(estimated_cost())
```

`estimated_cost()` uses `metrics.estimated_cost` when present and otherwise falls back to token metrics plus model pricing.

To match the preset’s scorer exclusion, add a filter like:

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
span_attributes.purpose is null or span_attributes.purpose != 'scorer'
```

## How to confirm it worked

* The Total LLM cost preset chart shows data after new spans are ingested.
* Sample spans used by the chart include token metrics and a non-null, recognized `metadata.model`.
* A custom chart using `sum(estimated_cost())` returns the expected cost when `metrics.estimated_cost` is logged directly.

## Notes

* The preset excludes internal scorer spans automatically. Add filters to your custom chart if you need the same exclusion.
