Chat Completions usage
usage object:
Successful streams end with a usage chunk before
data: [DONE]. You don’t need to set stream_options. See Streaming.
Responses usage
/v1/responses returns usage.input_tokens, usage.output_tokens, and usage.total_tokens. output_tokens includes reasoning tokens. input_tokens_details.cached_tokens is included when there are cached tokens, and non-streaming responses can include output_tokens_details.reasoning_tokens. In streams, usage is on the response.completed event.
Messages usage
/v1/messages returns usage.input_tokens, usage.output_tokens, usage.cache_read_input_tokens, and usage.cache_creation_input_tokens. In streams, final usage is on the message_delta event.
Prompt caching
Prompt caching is automatic. When a request starts with the same tokens as a recent request, Wafer reuses the cached prefix. You don’t need to sendcache_control or any other field. Cached tokens are reported as prompt_tokens_details.cached_tokens (Chat Completions), input_tokens_details.cached_tokens (Responses), or cache_read_input_tokens (Messages), and bill at the cache-read rate. Cache hits aren’t guaranteed.
To get more cache hits, keep the stable part of the prompt (system prompt, tool definitions, long documents) at the start and put changing content at the end.
How requests are billed
Serverless is prepaid. Each request is charged against your credit balance at the rates in the model’swafer.pricing card (see Pricing):
- Uncached prompt tokens (prompt tokens minus cached tokens) at
input_cents_per_million. - Cached prompt tokens at
cache_read_microcents_per_million. - Generated tokens, including reasoning tokens, at
output_cents_per_million.
max_tokens when reasoning is on; see Output length. Call GET /v1/models with your API key to see your account’s rates. Without a key, the cards show list prices.
Requests rejected before generation starts (authentication, validation, and rate-limit errors) are not charged. A stream that fails after it starts may be charged for tokens already generated. /v1/messages/count_tokens is free.
Before a request runs, Wafer checks that your balance covers its maximum possible cost. When it doesn’t, Wafer returns 402 with code insufficient_credits. See Credits.
Account usage API
GET https://api.wafer.ai/v1/usage returns your account’s requests, tokens, and billed cost over time. Authenticate with any API key on the account. The report covers every key on the account for that key’s endpoint.
The response has one entry in
data per bucket, including empty ones, and totals for the whole window. This excerpt of the response to the request above shows only the first of its 30 daily buckets, so totals is larger than that one bucket:
input_tokensincludescache_read_tokens, as in per-request usage.cost_usdis what each request was charged at your account’s rates, before invoice-level discounts or credits. Cost history starts on 2026-06-16; earlier buckets reportcost_usdasnull.- Cost is tracked per model, not per key. With
group_by=api_key, each key’scost_usdisnull; the bucket and window totals still include cost. - Usage under a model name that can’t be shown is grouped under
unavailable. cost_statusisbilledwhen cost is reported,not_applicablefor plans that aren’t billed per token, andunavailablewhen cost can’t be reported for this account (contact support).- Tokens are bucketed by request time and cost by billing time, so daily figures near midnight UTC can differ slightly. The most recent minutes may not be included yet.
Dashboard
The dashboard at app.wafer.ai shows your credit balance and usage, and is where you add credits. To track individual requests, use theusage object in each response and the x-request-id response header to correlate requests with your logs.