# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import httpx

from .v1.v1 import (
    V1Resource,
    AsyncV1Resource,
    V1ResourceWithRawResponse,
    AsyncV1ResourceWithRawResponse,
    V1ResourceWithStreamingResponse,
    AsyncV1ResourceWithStreamingResponse,
)
from ..._types import Body, Query, Headers, NotGiven, not_given
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
    to_raw_response_wrapper,
    to_streamed_response_wrapper,
    async_to_raw_response_wrapper,
    async_to_streamed_response_wrapper,
)
from ..._base_client import make_request_options
from ...types.llm_get_config_response import LlmGetConfigResponse

__all__ = ["LlmResource", "AsyncLlmResource"]


class LlmResource(SyncAPIResource):
    """Access 40+ language models through a unified API"""

    @cached_property
    def v1(self) -> V1Resource:
        """Access 40+ language models through a unified API"""
        return V1Resource(self._client)

    @cached_property
    def with_raw_response(self) -> LlmResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/CaseMark/casedev-python#accessing-raw-response-data-eg-headers
        """
        return LlmResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> LlmResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/CaseMark/casedev-python#with_streaming_response
        """
        return LlmResourceWithStreamingResponse(self)

    def get_config(
        self,
        *,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> LlmGetConfigResponse:
        """
        Retrieves the AI Gateway configuration including all available language models
        and their specifications. This endpoint returns model information compatible
        with the Vercel AI SDK Gateway format, making it easy to integrate with existing
        AI applications.

        Use this endpoint to:

        - Discover available language models
        - Get model specifications and pricing
        - Configure AI SDK clients
        - Build model selection interfaces
        """
        return self._get(
            "/llm/config",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=LlmGetConfigResponse,
        )


class AsyncLlmResource(AsyncAPIResource):
    """Access 40+ language models through a unified API"""

    @cached_property
    def v1(self) -> AsyncV1Resource:
        """Access 40+ language models through a unified API"""
        return AsyncV1Resource(self._client)

    @cached_property
    def with_raw_response(self) -> AsyncLlmResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/CaseMark/casedev-python#accessing-raw-response-data-eg-headers
        """
        return AsyncLlmResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncLlmResourceWithStreamingResponse:
        """
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/CaseMark/casedev-python#with_streaming_response
        """
        return AsyncLlmResourceWithStreamingResponse(self)

    async def get_config(
        self,
        *,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> LlmGetConfigResponse:
        """
        Retrieves the AI Gateway configuration including all available language models
        and their specifications. This endpoint returns model information compatible
        with the Vercel AI SDK Gateway format, making it easy to integrate with existing
        AI applications.

        Use this endpoint to:

        - Discover available language models
        - Get model specifications and pricing
        - Configure AI SDK clients
        - Build model selection interfaces
        """
        return await self._get(
            "/llm/config",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=LlmGetConfigResponse,
        )


class LlmResourceWithRawResponse:
    def __init__(self, llm: LlmResource) -> None:
        self._llm = llm

        self.get_config = to_raw_response_wrapper(
            llm.get_config,
        )

    @cached_property
    def v1(self) -> V1ResourceWithRawResponse:
        """Access 40+ language models through a unified API"""
        return V1ResourceWithRawResponse(self._llm.v1)


class AsyncLlmResourceWithRawResponse:
    def __init__(self, llm: AsyncLlmResource) -> None:
        self._llm = llm

        self.get_config = async_to_raw_response_wrapper(
            llm.get_config,
        )

    @cached_property
    def v1(self) -> AsyncV1ResourceWithRawResponse:
        """Access 40+ language models through a unified API"""
        return AsyncV1ResourceWithRawResponse(self._llm.v1)


class LlmResourceWithStreamingResponse:
    def __init__(self, llm: LlmResource) -> None:
        self._llm = llm

        self.get_config = to_streamed_response_wrapper(
            llm.get_config,
        )

    @cached_property
    def v1(self) -> V1ResourceWithStreamingResponse:
        """Access 40+ language models through a unified API"""
        return V1ResourceWithStreamingResponse(self._llm.v1)


class AsyncLlmResourceWithStreamingResponse:
    def __init__(self, llm: AsyncLlmResource) -> None:
        self._llm = llm

        self.get_config = async_to_streamed_response_wrapper(
            llm.get_config,
        )

    @cached_property
    def v1(self) -> AsyncV1ResourceWithStreamingResponse:
        """Access 40+ language models through a unified API"""
        return AsyncV1ResourceWithStreamingResponse(self._llm.v1)
