| 1 |
from typing import Optional |
| 2 |
from typing_extensions import Literal |
| 3 |
|
| 4 |
from .._models import BaseModel |
| 5 |
from .cache_creation import CacheCreation |
| 6 |
from .server_tool_usage import ServerToolUsage |
| 7 |
from .output_tokens_details import OutputTokensDetails |
| 8 |
|
| 9 |
__all__ = ["Usage"] |
| 10 |
|
| 11 |
|
| 12 |
class Usage(BaseModel): |
| 13 |
cache_creation: Optional[CacheCreation] = None |
| 14 |
"""Breakdown of cached tokens by TTL""" |
| 15 |
|
| 16 |
cache_creation_input_tokens: Optional[int] = None |
| 17 |
"""The number of input tokens used to create the cache entry.""" |
| 18 |
|
| 19 |
cache_read_input_tokens: Optional[int] = None |
| 20 |
"""The number of input tokens read from the cache.""" |
| 21 |
|
| 22 |
inference_geo: Optional[str] = None |
| 23 |
"""The geographic region where inference was performed for this request.""" |
| 24 |
|
| 25 |
input_tokens: int |
| 26 |
"""The number of input tokens which were used.""" |
| 27 |
|
| 28 |
output_tokens: int |
| 29 |
"""The number of output tokens which were used.""" |
| 30 |
|
| 31 |
output_tokens_details: Optional[OutputTokensDetails] = None |
| 32 |
"""Breakdown of output tokens by category. |
| 33 |
|
| 34 |
`output_tokens` remains the inclusive, authoritative total used for billing. |
| 35 |
This object provides a read-only decomposition for observability — for example, |
| 36 |
how many of the billed output tokens were spent on internal reasoning that may |
| 37 |
have been summarized before being returned to you. |
| 38 |
""" |
| 39 |
|
| 40 |
server_tool_use: Optional[ServerToolUsage] = None |
| 41 |
"""The number of server tool requests.""" |
| 42 |
|
| 43 |
service_tier: Optional[Literal["standard", "priority", "batch"]] = None |
| 44 |
"""If the request used the priority, standard, or batch tier.""" |