"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .chatgenerationtokenusage import (
    ChatGenerationTokenUsage,
    ChatGenerationTokenUsageTypedDict,
)
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
from openrouter.types import BaseModel
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict


ChatStreamingResponseChunkObject = Literal["chat.completion.chunk",]


class ErrorTypedDict(TypedDict):
    r"""Error information"""

    message: str
    r"""Error message"""
    code: float
    r"""Error code"""


class Error(BaseModel):
    r"""Error information"""

    message: str
    r"""Error message"""

    code: float
    r"""Error code"""


class ChatStreamingResponseChunkTypedDict(TypedDict):
    r"""Streaming chat completion chunk"""

    id: str
    r"""Unique chunk identifier"""
    choices: List[ChatStreamingChoiceTypedDict]
    r"""List of streaming chunk choices"""
    created: float
    r"""Unix timestamp of creation"""
    model: str
    r"""Model used for completion"""
    object: ChatStreamingResponseChunkObject
    system_fingerprint: NotRequired[str]
    r"""System fingerprint"""
    error: NotRequired[ErrorTypedDict]
    r"""Error information"""
    usage: NotRequired[ChatGenerationTokenUsageTypedDict]
    r"""Token usage statistics"""


class ChatStreamingResponseChunk(BaseModel):
    r"""Streaming chat completion chunk"""

    id: str
    r"""Unique chunk identifier"""

    choices: List[ChatStreamingChoice]
    r"""List of streaming chunk choices"""

    created: float
    r"""Unix timestamp of creation"""

    model: str
    r"""Model used for completion"""

    object: ChatStreamingResponseChunkObject

    system_fingerprint: Optional[str] = None
    r"""System fingerprint"""

    error: Optional[Error] = None
    r"""Error information"""

    usage: Optional[ChatGenerationTokenUsage] = None
    r"""Token usage statistics"""
