# 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
from .traces_get_analytics_summary_response_top_functions_item import (
    TracesGetAnalyticsSummaryResponseTopFunctionsItem,
)
from .traces_get_analytics_summary_response_top_models_item import (
    TracesGetAnalyticsSummaryResponseTopModelsItem,
)


class TracesGetAnalyticsSummaryResponse(UniversalBaseModel):
    total_spans: typing_extensions.Annotated[float, FieldMetadata(alias="totalSpans")]
    avg_duration_ms: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="avgDurationMs")
    ] = None
    p50duration_ms: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="p50DurationMs")
    ] = None
    p95duration_ms: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="p95DurationMs")
    ] = None
    p99duration_ms: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="p99DurationMs")
    ] = None
    error_rate: typing_extensions.Annotated[float, FieldMetadata(alias="errorRate")]
    total_tokens: typing_extensions.Annotated[float, FieldMetadata(alias="totalTokens")]
    total_cost_usd: typing_extensions.Annotated[
        float, FieldMetadata(alias="totalCostUsd")
    ]
    top_models: typing_extensions.Annotated[
        typing.List[TracesGetAnalyticsSummaryResponseTopModelsItem],
        FieldMetadata(alias="topModels"),
    ]
    top_functions: typing_extensions.Annotated[
        typing.List[TracesGetAnalyticsSummaryResponseTopFunctionsItem],
        FieldMetadata(alias="topFunctions"),
    ]

    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
