# `Alloy.Usage`
[🔗](https://github.com/alloy-ex/alloy/blob/v0.10.1/lib/alloy/usage.ex#L1)

Token usage tracking across turns.

Accumulates input/output token counts from provider responses
so callers can track costs and enforce limits.

# `t`

```elixir
@type t() :: %Alloy.Usage{
  cache_creation_input_tokens: non_neg_integer(),
  cache_read_input_tokens: non_neg_integer(),
  estimated_cost_cents: number(),
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer()
}
```

# `estimate_cost`

```elixir
@spec estimate_cost(t(), number(), number()) :: t()
```

Estimates cost in cents given per-million token prices.
Replaces (does not accumulate) the existing `estimated_cost_cents`.

# `merge`

```elixir
@spec merge(t(), map()) :: t()
```

Merges usage from a provider response into accumulated usage.

# `total`

```elixir
@spec total(t()) :: non_neg_integer()
```

Returns total tokens consumed (input + output).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
