# 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", default=None)
    """
    Cache creation input tokens
    """

    cache_read_input_tokens: typing_extensions.Annotated[
        typing.Optional[int], FieldMetadata(alias="cacheReadInputTokens")
    ] = pydantic.Field(alias="cacheReadInputTokens", default=None)
    """
    Cache read input tokens
    """

    cost_usd: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="costUsd")] = pydantic.Field(
        alias="costUsd", default=None
    )
    """
    Total cost in USD
    """

    duration_ms: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="durationMs")] = pydantic.Field(
        alias="durationMs", default=None
    )
    """
    Total duration in milliseconds
    """

    parent_tool_use_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="parentToolUseId")] = (
        pydantic.Field(alias="parentToolUseId", default=None)
    )
    """
    Parent tool use ID for subagent context
    """

    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
