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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawTokenCostClient, RawTokenCostClient
from .types.token_cost_calculate_request_usage import TokenCostCalculateRequestUsage
from .types.token_cost_calculate_response import TokenCostCalculateResponse

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


class TokenCostClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTokenCostClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawTokenCostClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawTokenCostClient
        """
        return self._raw_client

    def calculate(
        self,
        *,
        provider: str,
        model: str,
        usage: TokenCostCalculateRequestUsage,
        via_router: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TokenCostCalculateResponse:
        """
        Parameters
        ----------
        provider : str
            a non empty string

        model : str
            a non empty string

        usage : TokenCostCalculateRequestUsage

        via_router : typing.Optional[bool]

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

        Returns
        -------
        TokenCostCalculateResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope
        from mirascope.api._generated.token_cost import TokenCostCalculateRequestUsage

        client = Mirascope()
        client.token_cost.calculate(
            provider="provider",
            model="model",
            usage=TokenCostCalculateRequestUsage(
                input_tokens=1.1,
                output_tokens=1.1,
            ),
        )
        """
        _response = self._raw_client.calculate(
            provider=provider,
            model=model,
            usage=usage,
            via_router=via_router,
            request_options=request_options,
        )
        return _response.data


class AsyncTokenCostClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTokenCostClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawTokenCostClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawTokenCostClient
        """
        return self._raw_client

    async def calculate(
        self,
        *,
        provider: str,
        model: str,
        usage: TokenCostCalculateRequestUsage,
        via_router: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TokenCostCalculateResponse:
        """
        Parameters
        ----------
        provider : str
            a non empty string

        model : str
            a non empty string

        usage : TokenCostCalculateRequestUsage

        via_router : typing.Optional[bool]

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

        Returns
        -------
        TokenCostCalculateResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope
        from mirascope.api._generated.token_cost import TokenCostCalculateRequestUsage

        client = AsyncMirascope()


        async def main() -> None:
            await client.token_cost.calculate(
                provider="provider",
                model="model",
                usage=TokenCostCalculateRequestUsage(
                    input_tokens=1.1,
                    output_tokens=1.1,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.calculate(
            provider=provider,
            model=model,
            usage=usage,
            via_router=via_router,
            request_options=request_options,
        )
        return _response.data
