# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .custom_llm_api_key import CustomLlmApiKey
from .custom_llm_auth_connection import CustomLlmAuthConnection
from .custom_llm_request_headers_value import CustomLlmRequestHeadersValue
from .custom_llmapi_type import CustomLlmapiType


class CustomLlm(UncheckedBaseModel):
    url: str = pydantic.Field()
    """
    The URL of the Chat Completions compatible endpoint
    """

    model_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The model ID to be used if URL serves multiple models
    """

    api_key: typing.Optional[CustomLlmApiKey] = pydantic.Field(default=None)
    """
    The API key for authentication. Either a workspace secret reference {'secret_id': '...'} or an environment variable reference {'env_var_label': '...'}.
    """

    auth_connection: typing.Optional[CustomLlmAuthConnection] = pydantic.Field(default=None)
    """
    Optional workspace auth connection for authentication. Only auth connections that produce an Authorization Bearer token are supported; Basic auth, mTLS, custom header, and URL secret auth connections are not supported.
    """

    request_headers: typing.Optional[typing.Dict[str, CustomLlmRequestHeadersValue]] = pydantic.Field(default=None)
    """
    Headers that should be included in the request
    """

    api_version: typing.Optional[str] = pydantic.Field(default=None)
    """
    The API version to use for the request
    """

    api_type: typing.Optional[CustomLlmapiType] = pydantic.Field(default=None)
    """
    The API type to use (chat_completions, responses or websocket)
    """

    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
