usage block
The part of a model reply that reports how many tokens the call read and wrote, split by type, which is what you are billed for.
In more detail
Anthropic reports uncached input, cache writes and cache reads separately, with output (thinking included) on its own; OpenAI counts cached tokens inside its input total. Log usage with the request id on every call, and price each count at its own rate.
Related terms
- LLM token — The unit of text a language model reads and writes: a word, part of a word, a punctuation mark or a byte sequence from the tokenizer's vocabulary.
- prompt caching — Reusing a provider's stored work on an identical prompt prefix, so repeated calls cost less and start answering sooner.
- request id — The unique identifier a provider gives each API call, returned in a response header, that support staff can look up.
Taught in
- Tokens And The Context Window — AI Engineering: LLM Apps, RAG & Agents
- The Request And The Response — AI Engineering: LLM Apps, RAG & Agents
- Streaming Responses — AI Engineering: LLM Apps, RAG & Agents
- When The Call Fails — AI Engineering: LLM Apps, RAG & Agents
- Cost, Latency And Caching — AI Engineering: LLM Apps, RAG & Agents
- Anatomy Of A Prompt — AI Engineering: LLM Apps, RAG & Agents
- The Agent Loop — AI Engineering: LLM Apps, RAG & Agents
- Tracing And Monitoring — AI Engineering: LLM Apps, RAG & Agents
References
- Anthropic: Messages API reference (temperature, top_k, top_p, stop_sequences, stop_reason)
- Anthropic: Prompt caching