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

# Analytics

> Cost, latency, error rate, and model performance trends across all your projects.

Analytics aggregates the same telemetry you see in LLM Calls and Traces into trends you can act on at the team or portfolio level. Use it to spend less, not slower agents, and catch regressions across releases.

***

## What you can answer

<CardGroup cols={2}>
  <Card title="Where is my LLM bill going?" icon="dollar-sign">
    Cost by model and by agent, broken down per day. Drill into the dominant cost driver.
  </Card>

  <Card title="Are my agents getting slower?" icon="stopwatch">
    p50 / p95 / p99 latency over time, per agent and per model.
  </Card>

  <Card title="What's failing and how often?" icon="triangle-exclamation">
    Error rate per model and per agent, with click-through to the failing runs.
  </Card>

  <Card title="Which model is best for this job?" icon="trophy">
    Model performance comparison — cost, latency, and error rate side by side.
  </Card>
</CardGroup>

***

## Key endpoints

These are the analytics API endpoints the UI is built on. You can call them directly to feed BI tools.

| Endpoint                          | Returns                                  |
| --------------------------------- | ---------------------------------------- |
| `GET /api/analytics/usage/costs`  | Daily cost by model and agent.           |
| `GET /api/analytics/usage/models` | Per-model p50, p95, latency, error rate. |
| `GET /api/analytics/usage/agents` | Per-agent volume and cost.               |
| `GET /api/analytics/usage/errors` | Error breakdown by reason and model.     |

Filter parameters mirror the run filters: time range, app, agent, status, model.

***

## Cost tracking

Cost is computed at write time as `tokens × per-1k-token rate` for each LLM call. The rate table lives in `utils/model_costs.py`. Two consequences worth knowing:

* Adding a new model means adding a row to the cost table. Until that happens, calls with that model show `cost = 0`.
* Cost only applies to events of type `llm` — chain or tool spans don't accumulate cost themselves.

<Info>
  The cost column on the `Run` model is denormalised. Any backfill (price change, retroactive rate) requires re-running the cost recalc job.
</Info>

***

## Performance views

The **Model performance** view sorts models on three axes you usually care about together:

* p50 and p95 latency
* Error rate (errors ÷ total)
* Average cost per call

A model that's cheaper but ten times slower is only worth it for batch workloads. The view shows them side by side so the trade-off is visible.

***

## Related resources

<CardGroup cols={2}>
  <Card title="Drift Monitor" icon="wave-pulse" href="./drift-monitor">
    For distribution-level changes the aggregate charts miss.
  </Card>

  <Card title="Financial ROI" icon="dollar-sign" href="../roi/financial-roi">
    Turn cost and volume into per-agent ROI.
  </Card>
</CardGroup>
