Skip to content

toko_types

Class info

Classes

Name Children Inherits
ModelCapabilities
tokonomics.toko_types
Capabilities of a model.
    ModelCostTier
    tokonomics.toko_types
    Prices that apply to a request above a prompt size (LiteLLM's ``*_above_<N>k_tokens``).
      ModelCosts
      tokonomics.toko_types
      Cost information for a model.
        TokenCosts
        tokonomics.toko_types
        Detailed breakdown of token costs.
          TokenUsage
          tokonomics.toko_types
          Token usage statistics from model responses.

            🛈 DocStrings

            Tokonomics types.

            ModelCapabilities dataclass

            Capabilities of a model.

            Source code in src/tokonomics/toko_types.py
            @dataclass(frozen=True, slots=True)
            class ModelCapabilities:
                """Capabilities of a model."""
            
                max_tokens: int
                """Legacy parameter for maximum tokens"""
                max_input_tokens: int
                """Maximum input tokens supported"""
                max_output_tokens: int
                """Maximum output tokens supported"""
                litellm_provider: str | None
                """LiteLLM provider name"""
                mode: str | None
                """Model operation mode"""
                supports_function_calling: bool
                """Whether the model supports function calling"""
                supports_parallel_function_calling: bool
                """Whether the model supports parallel function calling"""
                supports_vision: bool
                """Whether the model supports vision/image input"""
                supports_audio_input: bool
                """Whether the model supports audio input"""
                supports_audio_output: bool
                """Whether the model supports audio output"""
                supports_prompt_caching: bool
                """Whether the model supports prompt caching"""
                supports_response_schema: bool
                """Whether the model supports response schema"""
                supports_system_messages: bool
                """Whether the model supports system messages"""
            

            litellm_provider instance-attribute

            litellm_provider: str | None
            

            LiteLLM provider name

            max_input_tokens instance-attribute

            max_input_tokens: int
            

            Maximum input tokens supported

            max_output_tokens instance-attribute

            max_output_tokens: int
            

            Maximum output tokens supported

            max_tokens instance-attribute

            max_tokens: int
            

            Legacy parameter for maximum tokens

            mode instance-attribute

            mode: str | None
            

            Model operation mode

            supports_audio_input instance-attribute

            supports_audio_input: bool
            

            Whether the model supports audio input

            supports_audio_output instance-attribute

            supports_audio_output: bool
            

            Whether the model supports audio output

            supports_function_calling instance-attribute

            supports_function_calling: bool
            

            Whether the model supports function calling

            supports_parallel_function_calling instance-attribute

            supports_parallel_function_calling: bool
            

            Whether the model supports parallel function calling

            supports_prompt_caching instance-attribute

            supports_prompt_caching: bool
            

            Whether the model supports prompt caching

            supports_response_schema instance-attribute

            supports_response_schema: bool
            

            Whether the model supports response schema

            supports_system_messages instance-attribute

            supports_system_messages: bool
            

            Whether the model supports system messages

            supports_vision instance-attribute

            supports_vision: bool
            

            Whether the model supports vision/image input

            ModelCostTier

            Bases: TypedDict

            Prices that apply to a request above a prompt size (LiteLLM's *_above_<N>k_tokens).

            Source code in src/tokonomics/toko_types.py
            class ModelCostTier(TypedDict, total=False):
                """Prices that apply to a request above a prompt size (LiteLLM's ``*_above_<N>k_tokens``)."""
            
                input_cost_per_token: Decimal
                output_cost_per_token: Decimal
                cache_read_input_token_cost: Decimal
                cache_creation_input_token_cost: Decimal
            

            ModelCosts

            Bases: TypedDict

            Cost information for a model.

            Source code in src/tokonomics/toko_types.py
            class ModelCosts(TypedDict):
                """Cost information for a model."""
            
                input_cost_per_token: Decimal
                output_cost_per_token: Decimal
                cache_read_input_token_cost: NotRequired[Decimal]
                """Price of an input token read from the prompt cache."""
                cache_creation_input_token_cost: NotRequired[Decimal]
                """Price of an input token written to the prompt cache."""
                tiers: NotRequired[dict[int, ModelCostTier]]
                """Prompt-size threshold (tokens) -> prices for requests with more input tokens."""
            

            cache_creation_input_token_cost instance-attribute

            cache_creation_input_token_cost: NotRequired[Decimal]
            

            Price of an input token written to the prompt cache.

            cache_read_input_token_cost instance-attribute

            cache_read_input_token_cost: NotRequired[Decimal]
            

            Price of an input token read from the prompt cache.

            tiers instance-attribute

            tiers: NotRequired[dict[int, ModelCostTier]]
            

            Prompt-size threshold (tokens) -> prices for requests with more input tokens.

            TokenCosts dataclass

            Detailed breakdown of token costs.

            Source code in src/tokonomics/toko_types.py
            @dataclass(frozen=True, slots=True)
            class TokenCosts:
                """Detailed breakdown of token costs."""
            
                input_cost: Decimal
                """Cost for prompt tokens"""
                output_cost: Decimal
                """Cost for completion tokens"""
            
                @property
                def total_cost(self) -> Decimal:
                    """Calculate total cost as sum of input and output costs."""
                    return self.input_cost + self.output_cost
            

            input_cost instance-attribute

            input_cost: Decimal
            

            Cost for prompt tokens

            output_cost instance-attribute

            output_cost: Decimal
            

            Cost for completion tokens

            total_cost property

            total_cost: Decimal
            

            Calculate total cost as sum of input and output costs.

            TokenUsage

            Bases: TypedDict

            Token usage statistics from model responses.

            Source code in src/tokonomics/toko_types.py
            class TokenUsage(TypedDict):
                """Token usage statistics from model responses."""
            
                total: int
                """Total tokens used"""
                prompt: int
                """Tokens used in the prompt"""
                completion: int
                """Tokens used in the completion"""
            

            completion instance-attribute

            completion: int
            

            Tokens used in the completion

            prompt instance-attribute

            prompt: int
            

            Tokens used in the prompt

            total instance-attribute

            total: int
            

            Total tokens used