# generated by datamodel-codegen:
#   filename:  tmp.PoSjVQlbWW.yml
#   timestamp: 2026-02-06T10:50:01+00:00

from typing import Any, Literal, NotRequired, TypedDict


class EmbeddingResponseData(TypedDict):
    object: NotRequired[str]
    embedding: list[float]
    index: NotRequired[int]


class Prediction(TypedDict, closed=True):
    """
    Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
    """

    type: NotRequired[Literal["content"]]
    content: NotRequired[str]


class TranscriptionSegmentChunk(TypedDict, closed=True):
    text: str
    start: float
    end: float
    score: NotRequired[float | None]
    speaker_id: NotRequired[str | None]
    type: NotRequired[Literal["transcription_segment"]]


class UsageInfo(TypedDict, closed=True):
    prompt_tokens: int
    completion_tokens: int
    total_tokens: int
    prompt_audio_seconds: NotRequired[int | None]


class ValidationError(TypedDict):
    loc: list[str | int]
    msg: str
    type: str


class Function(TypedDict, closed=True):
    name: str
    description: NotRequired[str]
    strict: NotRequired[bool]
    parameters: dict[str, Any]


class FunctionName(TypedDict, closed=True):
    """
    this restriction of `Function` is used to select a specific function to call
    """

    name: str


class JsonSchema(TypedDict, closed=True):
    name: str
    description: NotRequired[str | None]
    schema: dict[str, Any]
    strict: NotRequired[bool]


class AudioChunk(TypedDict, closed=True):
    input_audio: str | bytes
    type: NotRequired[Literal["input_audio"]]


class DocumentURLChunk(TypedDict, closed=True):
    document_url: str
    document_name: NotRequired[str | None]
    type: NotRequired[Literal["document_url"]]


class FileChunk(TypedDict, closed=True):
    type: NotRequired[Literal["file"]]
    file_id: str


class FunctionCall(TypedDict, closed=True):
    name: str
    arguments: dict[str, Any] | str


class ReferenceChunk(TypedDict, closed=True):
    reference_ids: list[int]
    type: NotRequired[Literal["reference"]]


class TextChunk(TypedDict, closed=True):
    text: str
    type: NotRequired[Literal["text"]]


class ThinkChunk(TypedDict, closed=True):
    thinking: list[ReferenceChunk | TextChunk]
    closed: NotRequired[bool]
    type: NotRequired[Literal["thinking"]]


class ImageURL(TypedDict, closed=True):
    url: str
    detail: NotRequired[str | None]


class AudioTranscriptionRequest(TypedDict):
    model: str
    file: NotRequired[bytes | None]
    file_url: NotRequired[str | None]
    file_id: NotRequired[str | None]
    language: NotRequired[str | None]
    temperature: NotRequired[float | None]
    stream: NotRequired[Literal[False]]
    diarize: NotRequired[bool]
    context_bias: NotRequired[list[str]]
    timestamp_granularities: NotRequired[list[Literal["segment", "word"]]]


class EmbeddingRequest(TypedDict, closed=True):
    model: str
    metadata: NotRequired[dict[str, Any] | None]
    input: str | list[str]
    output_dimension: NotRequired[int | None]
    output_dtype: NotRequired[Literal["float", "int8", "uint8", "binary", "ubinary"]]
    encoding_format: NotRequired[Literal["float", "base64"]]


class HTTPValidationError(TypedDict):
    detail: NotRequired[list[ValidationError]]


class TranscriptionResponse(TypedDict, closed=True):
    model: str
    text: str
    language: str | None
    segments: NotRequired[list[TranscriptionSegmentChunk]]
    usage: UsageInfo


class ResponseBase(TypedDict):
    id: NotRequired[str]
    object: NotRequired[str]
    model: NotRequired[str]
    usage: NotRequired[UsageInfo]


class ResponseFormat(TypedDict, closed=True):
    """
    Specify the format that the model must output. By default it will use `{ "type": "text" }`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ "type": "json_schema" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.
    """

    type: NotRequired[Literal["text", "json_object", "json_schema"]]
    json_schema: NotRequired[JsonSchema | None]


class Tool(TypedDict, closed=True):
    type: NotRequired[Literal["function"]]
    function: Function


class ToolChoice(TypedDict, closed=True):
    """
    ToolChoice is either a ToolChoiceEnum or a ToolChoice
    """

    type: NotRequired[Literal["function"]]
    function: FunctionName


class ToolCall(TypedDict, closed=True):
    id: NotRequired[str]
    type: NotRequired[Literal["function"]]
    function: FunctionCall
    index: NotRequired[int]


class ImageURLChunk(TypedDict, closed=True):
    """
    {"type":"image_url","image_url":{"url":"data:image/png;base64,iVBORw0
    """

    image_url: ImageURL | str
    type: NotRequired[Literal["image_url"]]


class EmbeddingResponse(TypedDict):
    data: list[EmbeddingResponseData]
    id: str
    object: str
    model: str
    usage: UsageInfo


class ChatCompletionResponseBase(ResponseBase):
    created: NotRequired[int]


class SystemMessage(TypedDict, closed=True):
    content: str | list[TextChunk | ThinkChunk]
    role: NotRequired[Literal["system"]]


class DeltaMessage(TypedDict):
    role: NotRequired[str | None]
    content: NotRequired[
        str
        | list[
            TextChunk
            | ImageURLChunk
            | DocumentURLChunk
            | ReferenceChunk
            | FileChunk
            | ThinkChunk
            | AudioChunk
        ]
        | None
    ]
    tool_calls: NotRequired[list[ToolCall] | None]


class AssistantMessage(TypedDict, closed=True):
    content: NotRequired[
        str
        | list[
            TextChunk
            | ImageURLChunk
            | DocumentURLChunk
            | ReferenceChunk
            | FileChunk
            | ThinkChunk
            | AudioChunk
        ]
        | None
    ]
    tool_calls: NotRequired[list[ToolCall] | None]
    prefix: NotRequired[bool]
    role: NotRequired[Literal["assistant"]]


class ChatCompletionChoice(TypedDict):
    index: int
    message: AssistantMessage
    finish_reason: Literal["stop", "length", "model_length", "error", "tool_calls"]


class ToolMessage(TypedDict, closed=True):
    content: (
        str
        | list[
            TextChunk
            | ImageURLChunk
            | DocumentURLChunk
            | ReferenceChunk
            | FileChunk
            | ThinkChunk
            | AudioChunk
        ]
        | None
    )
    tool_call_id: NotRequired[str | None]
    name: NotRequired[str | None]
    role: NotRequired[Literal["tool"]]


class UserMessage(TypedDict, closed=True):
    content: (
        str
        | list[
            TextChunk
            | ImageURLChunk
            | DocumentURLChunk
            | ReferenceChunk
            | FileChunk
            | ThinkChunk
            | AudioChunk
        ]
        | None
    )
    role: NotRequired[Literal["user"]]


class CompletionResponseStreamChoice(TypedDict):
    index: int
    delta: DeltaMessage
    finish_reason: Literal["stop", "length", "error", "tool_calls"] | None


class ChatCompletionRequest(TypedDict, closed=True):
    model: str
    temperature: NotRequired[float | None]
    top_p: NotRequired[float]
    max_tokens: NotRequired[int | None]
    stream: NotRequired[bool]
    stop: NotRequired[str | list[str]]
    random_seed: NotRequired[int | None]
    metadata: NotRequired[dict[str, Any] | None]
    messages: list[SystemMessage | UserMessage | AssistantMessage | ToolMessage]
    response_format: NotRequired[ResponseFormat]
    tools: NotRequired[list[Tool] | None]
    tool_choice: NotRequired[ToolChoice | Literal["auto", "none", "any", "required"]]
    presence_penalty: NotRequired[float]
    frequency_penalty: NotRequired[float]
    n: NotRequired[int | None]
    prediction: NotRequired[Prediction]
    parallel_tool_calls: NotRequired[bool]
    prompt_mode: NotRequired[Literal["reasoning"] | None]
    safe_prompt: NotRequired[bool]


class ChatCompletionResponse(TypedDict):
    choices: list[ChatCompletionChoice]
    id: str
    object: str
    data: Any
    model: str
    usage: UsageInfo
    created: Any


class CompletionChunk(TypedDict):
    id: str
    object: NotRequired[str]
    created: NotRequired[int]
    model: str
    usage: NotRequired[UsageInfo]
    choices: list[CompletionResponseStreamChoice]


class CompletionEvent(TypedDict):
    data: CompletionChunk
