LLM Analytics

Route: Analytics → LLM (/analytics/llm)

The default landing page after onboarding, and the page most teams keep open. It answers: how much am I calling models, what is it costing, and how is that trending?

LLM analytics overview


Page structure

┌─────────────────────────────────────────────────────────┐
│  Stat cards                                             │
│  Total requests · Total costs · Hallucination ·         │
│  Bias · Toxicity                                        │
├─────────────────────────────────────────────────────────┤
│  Requests per time                                      │
├─────────────────────────────────────────────────────────┤
│  Generation by categories  │  Generation by provider    │
│  Cost by environment       │  Cost by application       │
├─────────────────────────────────────────────────────────┤
│  Avg prompt tokens / request │ Avg completion tokens /  │
│                              │ request                  │
└─────────────────────────────────────────────────────────┘

Everything obeys the current project and time range.


Stat cards

LLM stat cards

Card What it counts Use it to
Total requests LLM calls in the window Spot traffic spikes and drops
Total costs Sum of computed cost across those calls Track spend against budget
Total hallucination detected Reserved counter — not populated in this release —
Total bias detected Reserved counter — not populated in this release —
Total toxicity detected Reserved counter — not populated in this release —

How cost is calculated

Cost is computed in your process, by the SDK, at span creation time:

cost = (prompt_tokens / 1000 × prompt_price)
     + (completion_tokens / 1000 × completion_price)

Prices come from a pricing table the SDK fetches at trail.init(). Two consequences:

  • A model missing from the pricing table costs 0. New or self-hosted models are the usual culprits. Supply your own table with pricing_json= — see Configuration.
  • TrailAI's figure is an estimate, not your provider invoice. It ignores volume discounts, cached input pricing, batch discounts, and anything else negotiated. Use it for relative comparison — which application, model, or environment is expensive — and reconcile absolutes with your provider.

Requests per time

A time series of request volume, bucketed to suit the selected range.

Requests per time

What to look for:

  • Steady baseline with daily peaks — normal for user-facing apps.
  • A cliff to zero — an outage, or the SDK stopped exporting. Cross-check Exceptions.
  • An unexplained spike — a retry storm, a runaway agent loop, or a load test. Drill into Tracing for the same window.

Distribution charts

Four charts that break the window down by dimension.

Cost and generation distribution charts

Chart Splits by Answers
Generation by categories Operation category (chat, embedding, image, audio…) What kind of work dominates?
Generation by provider Provider (OpenAI, Anthropic, Cohere…) Where is my traffic going?
Cost by environment deployment.environment Is staging burning production money?
Cost by application service.name Which app is expensive?

Both cost charts depend entirely on you setting application_name and environment in trail.init(). Leave them at their defaults and every bar collapses into one called default — the charts become useless. Set them deliberately.


Token charts

Token charts

Chart Shows Watch for
Avg prompt tokens / request Mean input size A creeping rise means prompt bloat — usually unbounded conversation history or a growing RAG context
Avg completion tokens / request Mean output size Sudden growth may mean the model is rambling; consider max_tokens

Prompt tokens are usually the larger cost driver in RAG systems. If cost is rising faster than request volume, this chart is where you'll see why.


Exploring the page

Exploring LLM analytics


Worked example — "our bill doubled last week"

  1. Analytics → LLM, time range 30 days.
  2. Total costs confirms the jump and dates it.
  3. Cost by application — is one app responsible, or is it broad?
  4. Cost by environment — a staging or load-test spike is a common and easily-fixed cause.
  5. Generation by provider — did a model change? A more expensive model at flat volume shows up here as a shift in the mix.
  6. Avg prompt tokens / request — if this rose in step with cost while request volume stayed flat, the cause is prompt size, not traffic.
  7. Observations → Tracing, filtered to the guilty application and the days in question, to read actual requests.

That sequence — stat card → dimension chart → token chart → trace — resolves most cost questions in a few minutes.


Related