Files
github-actions[bot]GitHubspeakeasybotspeakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
4d4ff3efdd chore: 🐝 Update SDK - Generate (spec change merged) 0.11.30 (#448)
Co-authored-by: speakeasybot <bot@speakeasyapi.dev>
Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
2026-07-14 17:53:19 +00:00

20 lines
6.9 KiB
Plaintext

---
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) | \{<br/>"tool_calls_executed": 2,<br/>"tool_calls_requested": 2,<br/>"web_search_requests": 2<br/>} |
| `total_tokens` | *int* | :heavy_check_mark: | Total number of tokens | |