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

# Cost API

> Pull LLM cost, tokens and calls per model, by day or by month, for billing and chargeback

Use the Cost API to export what your organization spends on LLMs: cost, tokens and calls, broken down by model (or provider, user, agent, group or scope), by day or by month. It returns the same numbers as **Monitoring → Cost**, so exports match what admins see in the app.

> [!NOTE]
>
> The Cost API is part of the **Enterprise Edition**, like the Cost dashboard.

## Authenticate

Send an API key from **Profile → API Keys**:

```http theme={null}
X-API-Key: bow_...
```

`Authorization: Bearer bow_...` also works. Add `X-Organization-Id` when the key's user belongs to more than one organization.

What the caller sees follows Monitoring access:

| Caller | Result |
| - | - |
| Organization admin | Spend for the whole organization |
| Manager of one or more agents | Spend on the agents they manage only |
| Other members | `403` |

## Monthly cost per model

```bash theme={null}
curl "$BOW_URL/api/console/metrics/cost?group_by=model&granularity=month&item_series=true&start_date=2026-09-01&end_date=2026-11-30" \
  -H "X-API-Key: $BOW_API_KEY"
```

The response holds the total, a month-by-month series for the organization, and one row per model with its own months:

```json theme={null}
{
  "group_by": "model",
  "granularity": "month",
  "total_cost_usd": 0.1004,
  "total_tokens": 16150,
  "total_calls": 5,
  "timeseries": [
    { "date": "2026-09", "cost_usd": 0.073, "tokens": 11700, "calls": 2 },
    { "date": "2026-10", "cost_usd": 0.0, "tokens": 0, "calls": 0 },
    { "date": "2026-11", "cost_usd": 0.0274, "tokens": 4450, "calls": 3 }
  ],
  "items": [
    {
      "key": "<llm-model-id>",
      "label": "Claude Sonnet 4.5",
      "sublabel": "claude-sonnet-4-5",
      "total_cost_usd": 0.059,
      "total_tokens": 7700,
      "total_calls": 2,
      "series": [
        { "date": "2026-09", "cost_usd": 0.042, "tokens": 6000, "calls": 1 },
        { "date": "2026-10", "cost_usd": 0.0, "tokens": 0, "calls": 0 },
        { "date": "2026-11", "cost_usd": 0.017, "tokens": 1700, "calls": 1 }
      ]
    }
  ]
}
```

The example is shortened. Each item also carries `prompt_tokens`, `completion_tokens`, `cache_read_tokens`, `cache_creation_tokens`, `input_cost_usd`, `output_cost_usd` and `provider_type`. The response also carries the same token totals for the whole range.

## Parameters

| Parameter | Values | Default | What it does |
| - | - | - | - |
| `group_by` | `model`, `provider`, `user`, `data_source`, `group`, `scope` | `model` | The dimension of each row in `items`. |
| `granularity` | `day`, `month` | `day` | The bucket size of `timeseries` and of each item's `series`. Any other value returns `422`. |
| `item_series` | `true`, `false` | `false` | Adds a `series` to every row in `items`. |
| `start_date` | ISO date or date-time | Organization creation | First day of the range. |
| `end_date` | ISO date or date-time | Today | Last day of the range, included in full. |
| `data_source_ids` | Comma-separated agent IDs | All | Only spend on conversations that used these agents. |

## How the numbers add up

* **Periods are UTC.** Day buckets are keyed `YYYY-MM-DD` and month buckets `YYYY-MM`.
* **Every period is present.** A period with no usage comes back with zeros, so you can chart or tabulate the series directly.
* **Partial months hold only the range.** With `start_date=2026-09-15`, the `2026-09` bucket covers September 15 to 30.
* **Series reconcile with the totals.** The `timeseries` sums to `total_cost_usd`, `total_tokens` and `total_calls`. Each item's `series` sums to that item's totals. For `model`, `provider`, `user` and `scope`, the items in a period add up to that period in `timeseries`.
* **`data_source` and `group` can count a call more than once.** A call in a conversation that used two agents, or made by a user in two groups, counts in full under each. Their rows can add up to more than the total, which stays exact.
* **Tokens count cache once.** `tokens` includes cache reads and writes for providers that report them separately, such as Anthropic. For providers that already include cached tokens in the prompt count, such as OpenAI, they are not added again.
* **Cost is fixed when the call is made.** Each call is priced with the model's rates at that time. Changing a model's pricing later does not change past months.

> [!TIP]
>
> Use `granularity=month` for ranges longer than about a year. Daily series stop at roughly 400 days.

## Example: monthly spend by model as CSV

```bash theme={null}
curl -s "$BOW_URL/api/console/metrics/cost?group_by=model&granularity=month&item_series=true&start_date=2026-01-01&end_date=2026-12-31" \
  -H "X-API-Key: $BOW_API_KEY" |
  jq -r '["month","model","cost_usd","tokens","calls"],
         (.items[] as $m | $m.series[] | [.date, $m.label, .cost_usd, .tokens, .calls]) | @csv'
```

For totals by provider instead, use `group_by=provider`. To set spending caps, see [Quotas and usage limits](https://docs.bow.ai/observe-and-govern/quotas-and-usage-limits.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.