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

from __future__ import annotations
from openrouter.components import providerpreferences as components_providerpreferences
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


TypeImageURL = Literal["image_url",]


class ImageURLTypedDict(TypedDict):
    url: str


class ImageURL(BaseModel):
    url: str


class ContentImageURLTypedDict(TypedDict):
    type: TypeImageURL
    image_url: ImageURLTypedDict


class ContentImageURL(BaseModel):
    type: TypeImageURL

    image_url: ImageURL


TypeText = Literal["text",]


class ContentTextTypedDict(TypedDict):
    type: TypeText
    text: str


class ContentText(BaseModel):
    type: TypeText

    text: str


ContentTypedDict = TypeAliasType(
    "ContentTypedDict", Union[ContentTextTypedDict, ContentImageURLTypedDict]
)


Content = Annotated[
    Union[
        Annotated[ContentText, Tag("text")],
        Annotated[ContentImageURL, Tag("image_url")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


class InputTypedDict(TypedDict):
    content: List[ContentTypedDict]


class Input(BaseModel):
    content: List[Content]


InputUnionTypedDict = TypeAliasType(
    "InputUnionTypedDict",
    Union[str, List[str], List[float], List[List[float]], List[InputTypedDict]],
)


InputUnion = TypeAliasType(
    "InputUnion", Union[str, List[str], List[float], List[List[float]], List[Input]]
)


EncodingFormat = Union[
    Literal[
        "float",
        "base64",
    ],
    UnrecognizedStr,
]


class CreateEmbeddingsRequestTypedDict(TypedDict):
    input: InputUnionTypedDict
    model: str
    encoding_format: NotRequired[EncodingFormat]
    dimensions: NotRequired[int]
    user: NotRequired[str]
    provider: NotRequired[components_providerpreferences.ProviderPreferencesTypedDict]
    r"""Provider routing preferences for the request."""
    input_type: NotRequired[str]


class CreateEmbeddingsRequest(BaseModel):
    input: InputUnion

    model: str

    encoding_format: Annotated[
        Optional[EncodingFormat], PlainValidator(validate_open_enum(False))
    ] = None

    dimensions: Optional[int] = None

    user: Optional[str] = None

    provider: Optional[components_providerpreferences.ProviderPreferences] = None
    r"""Provider routing preferences for the request."""

    input_type: Optional[str] = None


Object = Literal["list",]


ObjectEmbedding = Literal["embedding",]


EmbeddingTypedDict = TypeAliasType("EmbeddingTypedDict", Union[List[float], str])


Embedding = TypeAliasType("Embedding", Union[List[float], str])


class CreateEmbeddingsDataTypedDict(TypedDict):
    object: ObjectEmbedding
    embedding: EmbeddingTypedDict
    index: NotRequired[float]


class CreateEmbeddingsData(BaseModel):
    object: ObjectEmbedding

    embedding: Embedding

    index: Optional[float] = None


class UsageTypedDict(TypedDict):
    prompt_tokens: float
    total_tokens: float
    cost: NotRequired[float]


class Usage(BaseModel):
    prompt_tokens: float

    total_tokens: float

    cost: Optional[float] = None


class CreateEmbeddingsResponseBodyTypedDict(TypedDict):
    r"""Embedding response"""

    object: Object
    data: List[CreateEmbeddingsDataTypedDict]
    model: str
    id: NotRequired[str]
    usage: NotRequired[UsageTypedDict]


class CreateEmbeddingsResponseBody(BaseModel):
    r"""Embedding response"""

    object: Object

    data: List[CreateEmbeddingsData]

    model: str

    id: Optional[str] = None

    usage: Optional[Usage] = None


CreateEmbeddingsResponseTypedDict = TypeAliasType(
    "CreateEmbeddingsResponseTypedDict",
    Union[CreateEmbeddingsResponseBodyTypedDict, str],
)


CreateEmbeddingsResponse = TypeAliasType(
    "CreateEmbeddingsResponse", Union[CreateEmbeddingsResponseBody, str]
)
