The Claude API response includes a 'usage' field. What information does this provide?
Select an answer to reveal the explanation.
Short Explanation
The usage field tells you exactly how many input tokens your prompt consumed and how many output tokens Claude generated. You need those two numbers to calculate the cost of that call.
Full Explanation
The 'usage' object in every Claude API response contains 'input_tokens' (count of tokens in the request including system prompt and messages), 'output_tokens' (count of tokens in Claude's response), and sometimes additional fields like 'cache_creation_input_tokens' and 'cache_read_input_tokens' when prompt caching is used. This data is essential for monitoring token consumption, calculating costs, debugging context window issues, and optimizing prompt lengths. The total number of API calls made this month is tracked in the Anthropic Console, not in a per-call response. The percentage of the rate limit consumed by this request is reported in response headers, not in the usage object. The model's confidence score for the response generated is not provided by Claude's API.