---
title: "ChatUsage"
---

Token usage statistics


## Fields

| Field                                                                                                                        | Type                                                                                                                         | Required                                                                                                                     | Description                                                                                                                  | Example                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `completion_tokens`                                                                                                          | *int*                                                                                                                        | :heavy_check_mark:                                                                                                           | Number of tokens in the completion                                                                                           |                                                                                                                              |
| `completion_tokens_details`                                                                                                  | [OptionalNullable[components.ChatUsageCompletionTokensDetails]](../components/chatusagecompletiontokensdetails.mdx)           | :heavy_minus_sign:                                                                                                           | Detailed completion token usage                                                                                              |                                                                                                                              |
| `cost`                                                                                                                       | *OptionalNullable[float]*                                                                                                    | :heavy_minus_sign:                                                                                                           | Cost of the completion                                                                                                       |                                                                                                                              |
| `cost_details`                                                                                                               | [OptionalNullable[components.CostDetails]](../components/costdetails.mdx)                                                     | :heavy_minus_sign:                                                                                                           | Breakdown of upstream inference costs                                                                                        | \{<br/>"upstream_inference_completions_cost": 0.0004,<br/>"upstream_inference_cost": null,<br/>"upstream_inference_prompt_cost": 0.0008<br/>} |
| `is_byok`                                                                                                                    | *Optional[bool]*                                                                                                             | :heavy_minus_sign:                                                                                                           | Whether a request was made using a Bring Your Own Key configuration                                                          |                                                                                                                              |
| `prompt_tokens`                                                                                                              | *int*                                                                                                                        | :heavy_check_mark:                                                                                                           | Number of tokens in the prompt                                                                                               |                                                                                                                              |
| `prompt_tokens_details`                                                                                                      | [OptionalNullable[components.ChatUsagePromptTokensDetails]](../components/chatusageprompttokensdetails.mdx)                   | :heavy_minus_sign:                                                                                                           | Detailed prompt token usage                                                                                                  |                                                                                                                              |
| `server_tool_use_details`                                                                                                    | [OptionalNullable[components.ServerToolUseDetails]](../components/servertoolusedetails.mdx)                                   | :heavy_minus_sign:                                                                                                           | Usage for server-side tool execution (e.g., web search)                                                                      |                                                                                                                              |
| `total_tokens`                                                                                                               | *int*                                                                                                                        | :heavy_check_mark:                                                                                                           | Total number of tokens                                                                                                       |                                                                                                                              |