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

# LLM Cost

> Spend analytics for every LLM request routed through the Igris gateway — broken down by model, connection, and time.

# LLM Cost

The LLM Cost screen at [app.igrisecurity.com/llm-cost](https://app.igrisecurity.com/llm-cost) shows spending analytics for all requests processed by the Igris LLM gateway. Cost data is derived from the `costCents`, `tokensIn`, `tokensOut`, `model`, and `provider` fields recorded on each `llm_call` audit event.

***

## Time range

A segmented control in the page header selects the reporting window:

| Option  | Window                |
| ------- | --------------------- |
| **24h** | Last 24 hours         |
| **7d**  | Last 7 days (default) |
| **30d** | Last 30 days          |
| **90d** | Last 90 days          |

All panels update when the range changes.

***

## Summary KPIs

Two rows of KPI cells appear at the top of the page.

**Primary metrics:**

| KPI                  | Description                                                             |
| -------------------- | ----------------------------------------------------------------------- |
| **Total Spend**      | Sum of `costCents` across all LLM calls in the period, displayed in USD |
| **Avg Cost/Call**    | `totalCents ÷ totalCalls`                                               |
| **Total Calls**      | Count of `llm_call` audit events in the period                          |
| **Active Providers** | Number of distinct providers with at least one call                     |

**Token metrics:**

| KPI                 | Description                                     |
| ------------------- | ----------------------------------------------- |
| **Input Tokens**    | Sum of `tokensIn`                               |
| **Output Tokens**   | Sum of `tokensOut`                              |
| **Avg Tokens/Call** | `(totalTokensIn + totalTokensOut) ÷ totalCalls` |

***

## Spend over time

A stacked bar chart plots daily spend in USD, with each provider as a separate series. The x-axis is date-bucketed by `date_trunc('day', timestamp)`. Hover a bar to see the dollar breakdown per provider for that day.

This chart only renders when there is at least one data point in the selected range.

***

## Top models by spend

A horizontal bar chart listing the top 10 models ranked by total `costCents`. Each bar shows the model identifier and formatted spend. The widest bar represents 100 %; all others are proportional.

***

## Top connections by spend

A horizontal bar chart listing the top 10 connection slugs ranked by total `costCents`. Useful for identifying which integrations are driving the most spend.

***

## Avg cost per call by connection

A horizontal bar chart ranking connections by their **average** cost per call (rather than total spend). This surfaces connections that use expensive models infrequently — connections that "Top Connections by Spend" can miss when they are outranked by high-volume, low-cost connections.

The label for each bar includes the connection slug and its total call count.

***

## Token usage by model

A horizontal bar chart ranking models by combined token consumption (`tokensIn + tokensOut`). Helps identify which models are the largest token consumers regardless of unit price.

***

## API

| Method | Path                                   | Description                                                      |
| ------ | -------------------------------------- | ---------------------------------------------------------------- |
| `GET`  | `/api/v1/llm-cost/summary?range=7d`    | Aggregated totals, top models, top connections, avg-cost ranking |
| `GET`  | `/api/v1/llm-cost/timeseries?range=7d` | Daily spend per provider for the stacked bar chart               |

**`range`** accepts `24h`, `7d`, `30d`, or `90d`. Defaults to `7d`.

### Summary response shape

```json theme={null}
{
  "totalCents": 1234,
  "totalCalls": 980,
  "totalTokensIn": 450000,
  "totalTokensOut": 120000,
  "topModels": [
    { "model": "claude-3-5-sonnet-20241022", "cents": 800, "calls": 600, "tokensIn": 300000, "tokensOut": 80000 }
  ],
  "topConnections": [
    { "slug": "prod-gateway", "cents": 950, "calls": 750 }
  ],
  "connectionsByAvgCost": [
    { "slug": "premium-agent", "avgCents": 42.5, "calls": 12 }
  ],
  "range": "7d"
}
```

### Timeseries response shape

```json theme={null}
[
  { "date": "2026-06-20T00:00:00.000Z", "provider": "anthropic", "cents": 120, "calls": 90 },
  { "date": "2026-06-20T00:00:00.000Z", "provider": "openai", "cents": 45, "calls": 30 }
]
```
