ChatUsage - Python SDK
ChatUsage - Python SDK
ChatUsage method reference
The Python SDK and docs are currently in beta. Report issues on GitHub.
Token usage statistics
ChatUsage - Python SDK
The Python SDK and docs are currently in beta. Report issues on GitHub.
Token usage statistics
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
completion_tokens | int | ✔️ | Number of tokens in the completion | |
completion_tokens_details | OptionalNullable[components.CompletionTokensDetails] | ➖ | Detailed completion token usage | |
cost | OptionalNullable[float] | ➖ | Cost of the completion | |
cost_details | OptionalNullable[components.CostDetails] | ➖ | Breakdown of upstream inference costs | {"upstream_inference_completions_cost": 0.0004,"upstream_inference_cost": null,"upstream_inference_prompt_cost": 0.0008} |
is_byok | Optional[bool] | ➖ | Whether a request was made using a Bring Your Own Key configuration | |
prompt_tokens | int | ✔️ | Number of tokens in the prompt | |
prompt_tokens_details | OptionalNullable[components.PromptTokensDetails] | ➖ | Detailed prompt token usage | |
total_tokens | int | ✔️ | Total number of tokens |