# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata


class StreamMetadata(UniversalBaseModel):
    """
    Extended metadata for finish events.
    """

    cache_creation_input_tokens: typing_extensions.Annotated[
        typing.Optional[int],
        FieldMetadata(alias="cacheCreationInputTokens"),
        pydantic.Field(alias="cacheCreationInputTokens", description="Cache creation input tokens"),
    ] = None
    cache_read_input_tokens: typing_extensions.Annotated[
        typing.Optional[int],
        FieldMetadata(alias="cacheReadInputTokens"),
        pydantic.Field(alias="cacheReadInputTokens", description="Cache read input tokens"),
    ] = None
    cost_usd: typing_extensions.Annotated[
        typing.Optional[float],
        FieldMetadata(alias="costUsd"),
        pydantic.Field(alias="costUsd", description="Total cost in USD"),
    ] = None
    duration_ms: typing_extensions.Annotated[
        typing.Optional[int],
        FieldMetadata(alias="durationMs"),
        pydantic.Field(alias="durationMs", description="Total duration in milliseconds"),
    ] = None
    parent_tool_use_id: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="parentToolUseId"),
        pydantic.Field(alias="parentToolUseId", description="Parent tool use ID for subagent context"),
    ] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
