What comes back
On
/v1/messages the same numbers arrive as input_tokens and output_tokens, because
an Anthropic SDK is parsing them.
Streaming does not cost you these numbers. The final data event carries
usage whether
or not you asked for it — see Streaming.What a failed call costs
Almost always nothing. of the errors this API can return are free; are not, and both are streams that came apart after the model had already produced output. That is a deliberately narrow exception. A rejected request, a model that was not available, a rate limit, a request that never reached a model — none of those produce a usage record, because none of them spent anything worth charging you for. The per-code table is on Errors.Seeing it again
Everything above is visible in the console after the call:- Requests — per call, with its
x-request-id, model, tokens and outcome. This is the page to open when a number surprises you. - Analytics — the same usage aggregated by day, model and API key, with a cost view beside it.
- Billing — credits, spending limit, auto-reload, invoices.
Credits and limits
Inference draws on credits. Two settings decide what happens when they run low, and both produce errors that are not retryable, because nothing about waiting changes them:Attributing spend
Two handles, and they behave differently:- One API key per deployment or environment. Usage is attributed per key in the console, so staging and production separate without you sending anything extra.
- The
userfield (ormetadata.user_idon/v1/messages) is echoed into that request’s log line so you can correlate with your own records. It is not kept on the usage record, so it cannot be used to break down a bill.
Next
Rate limits and quotas
What throttles you before money does.
Errors
Every code, with its billing column.