# GPU units

> What a GPU unit measures, how a model's pricing turns each call into GPU units, and where to read them per model and per caller.

Source: https://developers.manykind.ai/models/gpu-units/

A **GPU unit** is the one measure of compute every model is metered in, so the
usage of a language model, a speech model, and an embedding model adds up to a
single figure.

Each call is counted twice: in the model's own unit (tokens, audio seconds,
images, requests) and in GPU units. The model's own unit tells you how much you
sent; GPU units tell you what it cost in compute, on the same scale for every
model.

## How a call is priced

Every model declares its price in the `pricing` block of its `model.json`:

```text
"pricing": {
  "unit": "token",
  "inputCost": <GPU units per input token>,
  "outputCost": <GPU units per output token>
}
```

Read a model's pricing on its page in ROC's **Models** catalogue.

| Field | Meaning |
|---|---|
| `unit` | What the model counts. One of the units below. |
| `inputCost` | GPU units per input unit. |
| `outputCost` | GPU units per output unit. Omitted or `0` for a model that generates no counted output. |

| `unit` | Used by | Input counts | Output counts |
|---|---|---|---|
| `token` | Language models, embeddings | Prompt tokens | Generated tokens |
| `second`, `audio_second` | Speech models | Seconds of decoded audio | — |
| `image` | Vision models | Images | — |
| `request` | Models priced per call | Requests | — |
| `character` | Models priced per character | Characters | — |

A call costs:

```text
GPU units = input count × inputCost + output count × outputCost
```

The inference runtime that serves the model computes this from the model's own
`pricing` and returns the counts and the GPU units with each response. A model
without a `pricing` block meters 0 GPU units.

**Cached input tokens.** When an engine serves part of the prompt from a prompt
cache, it reports those tokens as cached. Cached tokens are a subset of the
input tokens and are priced at `inputCost` with the rest of the input.

## Remote models

Some catalogue models are served by an external provider rather than a GPU the
platform runs. ROC marks them **External** with the provider's name. Their
`pricing` is set so that a remote model's GPU units sit on the same scale as a
self-hosted model's. A
remote model always declares a non-zero `inputCost`: every call to it costs
provider money.

## Where GPU units are counted

The inference gateway counts each call's GPU units against the Agent Service's
bucket, per model and per **caller**.

The caller is the request's `X-Caller` header:

| Caller | Who sends it |
|---|---|
| The agent's alias | Agents that run on Manykind, on every model call they make. |
| `playground`, `ask`, `assistant` | ROC: the model Playground, Ask, and the Workflow Builder assistant. |
| `none` | A call without the header, such as a direct API call. |
| `invalid` | A header that is not 1–128 characters of `A-Z a-z 0-9 . _ : + -`. |
| `other` | Callers beyond the per-bucket limit on distinct callers, counted together. ROC shows them as **Other callers**. |

Set `X-Caller` on your own direct calls to the gateway to see them as a caller
of their own. An agent's alias always matches the allowed characters.

GPU units also count toward a connection's **Compute limit**. See
[Spend limits](https://developers.manykind.ai/agents/ship/connect-to-a-vault/#spend-limits).

## Read them in ROC

Open **Models › Usage** in ROC's side navigation.

- The **GPU units** tile is the headline: the selected range's total for the
  models in the filter.
- The **GPU units** chart and the chart beside it, which counts in the models'
  own unit, each switch between **By model** and **By caller**.
- The **Models** table lists each model with its **Kind**, its count in its own
  unit (**Tokens**, **Audio**, **Images**, or **Requests**), its **GPU units**,
  and its **Share** of the total.
- **Export CSV** writes `gpu_units` beside `tokens_input`,
  `tokens_input_cached`, `tokens_output`, `audio_seconds`, and `images`.

<!-- shot: models-usage | /models/usage | the Usage page with the GPU units tile and the By model / By caller chart -->

To compare models of different kinds, read GPU units. To see how much of
something a model processed, read its own unit. Token counts are input plus
output; the cached tokens are already inside the input.

## Read them from the API

The inference gateway serves your bucket's usage history:

```text
GET /api/v1/metrics?metric=inference_gateway_gpu_units_total&from=&to=&step=&groupBy=
```

The bucket is always the one in your token. Two metrics carry the figures on
this page:

| Metric | Labels you can filter and group by |
|---|---|
| `inference_gateway_gpu_units_total` | `model`, `caller` |
| `inference_gateway_usage_total` | `model`, `caller`, `unit`, `direction` (`input`, `output`, `cached`) |

| Param | Meaning |
|---|---|
| `metric` | The metric name. |
| `from`, `to` | RFC 3339 times. |
| `step` | A duration (`60s`, `5m`, `1d`). With `step`, a range query; without it, one value at `to`. |
| `stat` | `rate` (default) or `increase`. |
| `window` | The lookback of `stat`. Default `5m`. |
| `groupBy` | One label of the metric, such as `model` or `caller`. |
| `<label>=<value>` | Keep only that label value, such as `caller=playground`. |

`direction="cached"` is the cached part of `direction="input"`, not an addition
to it.

## Related

- [Models](https://developers.manykind.ai/agents/building-blocks/models/)
- [Spend limits](https://developers.manykind.ai/agents/ship/connect-to-a-vault/#spend-limits)
- [Monitor runs](https://developers.manykind.ai/agents/workflows/monitor-runs/)
- [Next: Cubbies](https://developers.manykind.ai/agents/building-blocks/cubbies/)
