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

import typing
from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.model_provider_connection import ModelProviderConnection
from ..core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.provider_enum import ProviderEnum
from ..types.scope_enum import ScopeEnum
from .types.list_model_provider_choices_model_providers_response import ListModelProviderChoicesModelProvidersResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.client_wrapper import AsyncClientWrapper

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class ModelProvidersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ModelProviderConnection]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all model provider connections.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ModelProviderConnection]


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.list()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/",
            method="GET",
            params={
                "ordering": ordering,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[ModelProviderConnection],
                    construct_type(
                        type_=typing.List[ModelProviderConnection],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def create(
        self,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Create a new model provider connection.

        Parameters
        ----------
        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.create()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/",
            method="POST",
            json={
                "api_key": api_key,
                "auth_token": auth_token,
                "budget_alert_threshold": budget_alert_threshold,
                "cached_available_models": cached_available_models,
                "deployment_name": deployment_name,
                "endpoint": endpoint,
                "google_application_credentials": google_application_credentials,
                "google_location": google_location,
                "google_project_id": google_project_id,
                "is_internal": is_internal,
                "provider": provider,
                "scope": scope,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def list_model_provider_choices(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListModelProviderChoicesModelProvidersResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all possible model provider choices

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ListModelProviderChoicesModelProvidersResponse
            List of model provider choices

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.list_model_provider_choices()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/provider-choices",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ListModelProviderChoicesModelProvidersResponse,
                    construct_type(
                        type_=ListModelProviderChoicesModelProvidersResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve a specific model provider connection.

        Parameters
        ----------
        id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.get(
            id="id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Delete a model provider connection by ID

        Parameters
        ----------
        id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.delete(
            id="id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def update(
        self,
        id: str,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update a specific model provider connection by ID.

        Parameters
        ----------
        id : str

        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.model_providers.update(
            id="id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="PATCH",
            json={
                "api_key": api_key,
                "auth_token": auth_token,
                "budget_alert_threshold": budget_alert_threshold,
                "cached_available_models": cached_available_models,
                "deployment_name": deployment_name,
                "endpoint": endpoint,
                "google_application_credentials": google_application_credentials,
                "google_location": google_location,
                "google_project_id": google_project_id,
                "is_internal": is_internal,
                "provider": provider,
                "scope": scope,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncModelProvidersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def list(
        self, *, ordering: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ModelProviderConnection]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all model provider connections.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[ModelProviderConnection]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.list()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/",
            method="GET",
            params={
                "ordering": ordering,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[ModelProviderConnection],
                    construct_type(
                        type_=typing.List[ModelProviderConnection],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def create(
        self,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Create a new model provider connection.

        Parameters
        ----------
        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.create()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/",
            method="POST",
            json={
                "api_key": api_key,
                "auth_token": auth_token,
                "budget_alert_threshold": budget_alert_threshold,
                "cached_available_models": cached_available_models,
                "deployment_name": deployment_name,
                "endpoint": endpoint,
                "google_application_credentials": google_application_credentials,
                "google_location": google_location,
                "google_project_id": google_project_id,
                "is_internal": is_internal,
                "provider": provider,
                "scope": scope,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def list_model_provider_choices(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListModelProviderChoicesModelProvidersResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all possible model provider choices

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ListModelProviderChoicesModelProvidersResponse
            List of model provider choices

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.list_model_provider_choices()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/model-provider-connections/provider-choices",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ListModelProviderChoicesModelProvidersResponse,
                    construct_type(
                        type_=ListModelProviderChoicesModelProvidersResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve a specific model provider connection.

        Parameters
        ----------
        id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.get(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Delete a model provider connection by ID

        Parameters
        ----------
        id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.delete(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def update(
        self,
        id: str,
        *,
        api_key: typing.Optional[str] = OMIT,
        auth_token: typing.Optional[str] = OMIT,
        budget_alert_threshold: typing.Optional[float] = OMIT,
        cached_available_models: typing.Optional[str] = OMIT,
        deployment_name: typing.Optional[str] = OMIT,
        endpoint: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_location: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        is_internal: typing.Optional[bool] = OMIT,
        provider: typing.Optional[ProviderEnum] = OMIT,
        scope: typing.Optional[ScopeEnum] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelProviderConnection:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Update a specific model provider connection by ID.

        Parameters
        ----------
        id : str

        api_key : typing.Optional[str]
            Model provider API key

        auth_token : typing.Optional[str]
            Model provider Auth token

        budget_alert_threshold : typing.Optional[float]
            Budget alert threshold for the given provider connection

        cached_available_models : typing.Optional[str]
            List of available models from the provider

        deployment_name : typing.Optional[str]
            Azure OpenAI deployment name

        endpoint : typing.Optional[str]
            Azure OpenAI endpoint

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file

        google_location : typing.Optional[str]
            Google project location

        google_project_id : typing.Optional[str]
            Google project ID

        is_internal : typing.Optional[bool]
            Whether the model provider connection is internal, not visible to the user

        provider : typing.Optional[ProviderEnum]

        scope : typing.Optional[ScopeEnum]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ModelProviderConnection


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.model_providers.update(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/model-provider-connections/{jsonable_encoder(id)}/",
            method="PATCH",
            json={
                "api_key": api_key,
                "auth_token": auth_token,
                "budget_alert_threshold": budget_alert_threshold,
                "cached_available_models": cached_available_models,
                "deployment_name": deployment_name,
                "endpoint": endpoint,
                "google_application_credentials": google_application_credentials,
                "google_location": google_location,
                "google_project_id": google_project_id,
                "is_internal": is_internal,
                "provider": provider,
                "scope": scope,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelProviderConnection,
                    construct_type(
                        type_=ModelProviderConnection,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
