Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions google/genai/tests/common/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,18 @@ def test_repr_complex_object():
assert repr(obj) == expected


def test_generate_content_usage_metadata_service_tier():
response = types.GenerateContentResponse.model_validate({
'usageMetadata': {
'promptTokenCount': 1,
'totalTokenCount': 1,
'serviceTier': 'priority',
}
})

assert response.usage_metadata.service_tier == types.ServiceTier.PRIORITY


def test_move_value_by_path():
"""Test move_value_by_path function with array wildcard notation."""
data = {
Expand Down
7 changes: 7 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7809,6 +7809,10 @@ class GenerateContentResponseUsageMetadata(_common.BaseModel):
default=None,
description="""Output only. A detailed breakdown of the token count for each modality in the prompt.""",
)
service_tier: Optional[ServiceTier] = Field(
default=None,
description="""Output only. The service tier used for this request.""",
)
thoughts_token_count: Optional[int] = Field(
default=None,
description="""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""",
Expand Down Expand Up @@ -7856,6 +7860,9 @@ class GenerateContentResponseUsageMetadataDict(TypedDict, total=False):
prompt_tokens_details: Optional[list[ModalityTokenCountDict]]
"""Output only. A detailed breakdown of the token count for each modality in the prompt."""

service_tier: Optional[ServiceTier]
"""Output only. The service tier used for this request."""

thoughts_token_count: Optional[int]
"""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable."""

Expand Down