Skip to content

ChatCompletionModel

Base classes

Name Children Inherits
TextGenerationModel
tokonomics.data_models
Base for text generation models (chat, completion, responses).

⋔ Inheritance diagram

graph TD
  705403162["data_models.ChatCompletionModel"]
  1919614333["data_models.TextGenerationModel"]
  823585605["data_models.BaseModelConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  1919614333 --> 705403162
  823585605 --> 1919614333
  330168112 --> 823585605
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: TextGenerationModel

Chat and completion models with comprehensive pricing and capability support.

Source code in src/tokonomics/data_models.py
class ChatCompletionModel(TextGenerationModel):
    """Chat and completion models with comprehensive pricing and capability support."""

    mode: Literal[ModelMode.CHAT, ModelMode.COMPLETION]
    """Model operation mode."""

    # Extended pricing options
    input_cost_per_token_above_200k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per token above 200k tokens."""

    output_cost_per_token_above_200k_tokens: Decimal | None = Field(None, ge=0)
    """Output cost per token above 200k tokens."""

    input_cost_per_token_above_1hr: Decimal | None = Field(None, ge=0)
    """Input cost per token above 1 hour."""

    input_cost_per_token_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per token above 128k tokens."""

    output_cost_per_token_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Output cost per token above 128k tokens."""

    output_cost_per_reasoning_token: Decimal | None = Field(None, ge=0)
    """Cost per reasoning output token."""

    # Priority pricing
    cache_read_input_token_cost_priority: Decimal | None = Field(None, ge=0)
    """Cache read input token cost for priority requests."""

    input_cost_per_token_priority: Decimal | None = Field(None, ge=0)
    """Input cost per token for priority requests."""

    output_cost_per_token_priority: Decimal | None = Field(None, ge=0)
    """Output cost per token for priority requests."""

    # Flex pricing
    cache_read_input_token_cost_flex: Decimal | None = Field(None, ge=0)
    """Cache read input token cost for flex requests."""

    input_cost_per_token_flex: Decimal | None = Field(None, ge=0)
    """Input cost per token for flex requests."""

    output_cost_per_token_flex: Decimal | None = Field(None, ge=0)
    """Output cost per token for flex requests."""

    # Image token pricing
    cache_read_input_image_token_cost: Decimal | None = Field(None, ge=0)
    """Cache read input image token cost."""

    input_cost_per_image_token: Decimal | None = Field(None, ge=0)
    """Input cost per image token."""

    output_cost_per_image_token: Decimal | None = Field(None, ge=0)
    """Output cost per image token."""

    # Request-based pricing
    input_cost_per_request: Decimal | None = Field(None, ge=0)
    """Input cost per request."""

    citation_cost_per_token: Decimal | None = Field(None, ge=0)
    """Citation cost per token."""

    # OpenAI service-specific costs
    code_interpreter_cost_per_session: Decimal | None = Field(None, ge=0)
    """Code interpreter cost per session."""

    computer_use_input_cost_per_1k_tokens: Decimal | None = Field(None, ge=0)
    """Computer use input cost per 1k tokens."""

    computer_use_output_cost_per_1k_tokens: Decimal | None = Field(None, ge=0)
    """Computer use output cost per 1k tokens."""

    file_search_cost_per_1k_calls: Decimal | None = Field(None, ge=0)
    """File search cost per 1k calls."""

    file_search_cost_per_gb_per_day: Decimal | None = Field(None, ge=0)
    """File search cost per GB per day."""

    vector_store_cost_per_gb_per_day: Decimal | None = Field(None, ge=0)
    """Vector store cost per GB per day."""

    # Caching pricing
    cache_creation_input_token_cost: Decimal | None = Field(None, ge=0)
    """Cache creation input token cost."""

    cache_creation_input_token_cost_above_200k_tokens: Decimal | None = Field(None, ge=0)
    """Cache creation input token cost above 200k tokens."""

    cache_creation_input_token_cost_above_1hr: Decimal | None = Field(None, ge=0)
    """Cache creation input token cost above 1 hour."""

    cache_read_input_token_cost_above_200k_tokens: Decimal | None = Field(None, ge=0)
    """Cache read input token cost above 200k tokens."""

    input_cost_per_token_cache_hit: Decimal | None = Field(None, ge=0)
    """Input cost per token for cache hits."""

    cache_creation_input_audio_token_cost: Decimal | None = Field(None, ge=0)
    """Cache creation input audio token cost."""

    cache_read_input_audio_token_cost: Decimal | None = Field(None, ge=0)
    """Cache read input audio token cost."""

    # Databricks DBU-based pricing
    input_dbu_cost_per_token: Decimal | None = Field(None, ge=0)
    """Input DBU cost per token."""

    output_dbu_cost_per_token: Decimal | None = Field(None, ge=0)
    """Output DBU cost per token."""

    output_db_cost_per_token: Decimal | None = Field(None, ge=0)
    """Output DB cost per token."""

    # Legacy character-based pricing
    input_cost_per_character: Decimal | None = Field(None, ge=0)
    """Input cost per character."""

    output_cost_per_character: Decimal | None = Field(None, ge=0)
    """Output cost per character."""

    input_cost_per_character_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per character above 128k tokens."""

    output_cost_per_character_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Output cost per character above 128k tokens."""

    # Multimodal pricing
    input_cost_per_image: Decimal | None = Field(None, ge=0)
    """Input cost per image."""

    input_cost_per_image_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per image above 128k tokens."""

    input_cost_per_video_per_second: Decimal | None = Field(None, ge=0)
    """Input cost per video per second."""

    input_cost_per_video_per_second_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per video per second above 128k tokens."""

    input_cost_per_audio_per_second: Decimal | None = Field(None, ge=0)
    """Input cost per audio per second."""

    input_cost_per_audio_per_second_above_128k_tokens: Decimal | None = Field(None, ge=0)
    """Input cost per audio per second above 128k tokens."""

    input_cost_per_audio_token: Decimal | None = Field(None, ge=0)
    """Input cost per audio token."""

    output_cost_per_audio_token: Decimal | None = Field(None, ge=0)
    """Output cost per audio token."""

    output_cost_per_image: Decimal | None = Field(None, ge=0)
    """Output cost per image."""

    # Time-based pricing (for some chat models)
    input_cost_per_second: Decimal | None = Field(None, ge=0)
    """Input cost per second."""

    output_cost_per_second: Decimal | None = Field(None, ge=0)
    """Output cost per second."""

    # Multimodal limits
    max_images_per_prompt: int | None = Field(None, gt=0)
    """Maximum images per prompt."""

    max_videos_per_prompt: int | None = Field(None, gt=0)
    """Maximum videos per prompt."""

    max_video_length: float | None = Field(None, gt=0)
    """Max video length in hours."""

    max_audio_per_prompt: int | None = Field(None, gt=0)
    """Maximum audio files per prompt."""

    max_audio_length_hours: float | None = Field(None, gt=0)
    """Maximum audio length in hours."""

    max_pdf_size_mb: float | None = Field(None, gt=0)
    """Maximum PDF size in MB."""

    # Core capabilities

    supports_assistant_prefill: bool | None = None
    """Whether model supports assistant prefill."""

    # Advanced capabilities

    supports_audio_input: bool | None = None
    """Whether model supports audio input."""

    supports_audio_output: bool | None = None
    """Whether model supports audio output."""

    supports_video_input: bool | None = None
    """Whether model supports video input."""

    supports_url_context: bool | None = None
    """Whether model supports URL context."""

    supports_computer_use: bool | None = None
    """Whether model supports computer use."""

    supports_service_tier: bool | None = None
    """Whether model supports service tier selection."""

    # API support

    supported_regions: list[SupportedRegion | str] | None = None
    """List of supported regions."""

    rpd: int | None = None
    """Rate per day."""

cache_creation_input_audio_token_cost class-attribute instance-attribute

cache_creation_input_audio_token_cost: Decimal | None = Field(None, ge=0)

Cache creation input audio token cost.

cache_creation_input_token_cost class-attribute instance-attribute

cache_creation_input_token_cost: Decimal | None = Field(None, ge=0)

Cache creation input token cost.

cache_creation_input_token_cost_above_1hr class-attribute instance-attribute

cache_creation_input_token_cost_above_1hr: Decimal | None = Field(None, ge=0)

Cache creation input token cost above 1 hour.

cache_creation_input_token_cost_above_200k_tokens class-attribute instance-attribute

cache_creation_input_token_cost_above_200k_tokens: Decimal | None = Field(None, ge=0)

Cache creation input token cost above 200k tokens.

cache_read_input_audio_token_cost class-attribute instance-attribute

cache_read_input_audio_token_cost: Decimal | None = Field(None, ge=0)

Cache read input audio token cost.

cache_read_input_image_token_cost class-attribute instance-attribute

cache_read_input_image_token_cost: Decimal | None = Field(None, ge=0)

Cache read input image token cost.

cache_read_input_token_cost_above_200k_tokens class-attribute instance-attribute

cache_read_input_token_cost_above_200k_tokens: Decimal | None = Field(None, ge=0)

Cache read input token cost above 200k tokens.

cache_read_input_token_cost_flex class-attribute instance-attribute

cache_read_input_token_cost_flex: Decimal | None = Field(None, ge=0)

Cache read input token cost for flex requests.

cache_read_input_token_cost_priority class-attribute instance-attribute

cache_read_input_token_cost_priority: Decimal | None = Field(None, ge=0)

Cache read input token cost for priority requests.

citation_cost_per_token class-attribute instance-attribute

citation_cost_per_token: Decimal | None = Field(None, ge=0)

Citation cost per token.

code_interpreter_cost_per_session class-attribute instance-attribute

code_interpreter_cost_per_session: Decimal | None = Field(None, ge=0)

Code interpreter cost per session.

computer_use_input_cost_per_1k_tokens class-attribute instance-attribute

computer_use_input_cost_per_1k_tokens: Decimal | None = Field(None, ge=0)

Computer use input cost per 1k tokens.

computer_use_output_cost_per_1k_tokens class-attribute instance-attribute

computer_use_output_cost_per_1k_tokens: Decimal | None = Field(None, ge=0)

Computer use output cost per 1k tokens.

file_search_cost_per_1k_calls class-attribute instance-attribute

file_search_cost_per_1k_calls: Decimal | None = Field(None, ge=0)

File search cost per 1k calls.

file_search_cost_per_gb_per_day class-attribute instance-attribute

file_search_cost_per_gb_per_day: Decimal | None = Field(None, ge=0)

File search cost per GB per day.

input_cost_per_audio_per_second class-attribute instance-attribute

input_cost_per_audio_per_second: Decimal | None = Field(None, ge=0)

Input cost per audio per second.

input_cost_per_audio_per_second_above_128k_tokens class-attribute instance-attribute

input_cost_per_audio_per_second_above_128k_tokens: Decimal | None = Field(None, ge=0)

Input cost per audio per second above 128k tokens.

input_cost_per_audio_token class-attribute instance-attribute

input_cost_per_audio_token: Decimal | None = Field(None, ge=0)

Input cost per audio token.

input_cost_per_character class-attribute instance-attribute

input_cost_per_character: Decimal | None = Field(None, ge=0)

Input cost per character.

input_cost_per_character_above_128k_tokens class-attribute instance-attribute

input_cost_per_character_above_128k_tokens: Decimal | None = Field(None, ge=0)

Input cost per character above 128k tokens.

input_cost_per_image class-attribute instance-attribute

input_cost_per_image: Decimal | None = Field(None, ge=0)

Input cost per image.

input_cost_per_image_above_128k_tokens class-attribute instance-attribute

input_cost_per_image_above_128k_tokens: Decimal | None = Field(None, ge=0)

Input cost per image above 128k tokens.

input_cost_per_image_token class-attribute instance-attribute

input_cost_per_image_token: Decimal | None = Field(None, ge=0)

Input cost per image token.

input_cost_per_request class-attribute instance-attribute

input_cost_per_request: Decimal | None = Field(None, ge=0)

Input cost per request.

input_cost_per_second class-attribute instance-attribute

input_cost_per_second: Decimal | None = Field(None, ge=0)

Input cost per second.

input_cost_per_token_above_128k_tokens class-attribute instance-attribute

input_cost_per_token_above_128k_tokens: Decimal | None = Field(None, ge=0)

Input cost per token above 128k tokens.

input_cost_per_token_above_1hr class-attribute instance-attribute

input_cost_per_token_above_1hr: Decimal | None = Field(None, ge=0)

Input cost per token above 1 hour.

input_cost_per_token_above_200k_tokens class-attribute instance-attribute

input_cost_per_token_above_200k_tokens: Decimal | None = Field(None, ge=0)

Input cost per token above 200k tokens.

input_cost_per_token_cache_hit class-attribute instance-attribute

input_cost_per_token_cache_hit: Decimal | None = Field(None, ge=0)

Input cost per token for cache hits.

input_cost_per_token_flex class-attribute instance-attribute

input_cost_per_token_flex: Decimal | None = Field(None, ge=0)

Input cost per token for flex requests.

input_cost_per_token_priority class-attribute instance-attribute

input_cost_per_token_priority: Decimal | None = Field(None, ge=0)

Input cost per token for priority requests.

input_cost_per_video_per_second class-attribute instance-attribute

input_cost_per_video_per_second: Decimal | None = Field(None, ge=0)

Input cost per video per second.

input_cost_per_video_per_second_above_128k_tokens class-attribute instance-attribute

input_cost_per_video_per_second_above_128k_tokens: Decimal | None = Field(None, ge=0)

Input cost per video per second above 128k tokens.

input_dbu_cost_per_token class-attribute instance-attribute

input_dbu_cost_per_token: Decimal | None = Field(None, ge=0)

Input DBU cost per token.

max_audio_length_hours class-attribute instance-attribute

max_audio_length_hours: float | None = Field(None, gt=0)

Maximum audio length in hours.

max_audio_per_prompt class-attribute instance-attribute

max_audio_per_prompt: int | None = Field(None, gt=0)

Maximum audio files per prompt.

max_images_per_prompt class-attribute instance-attribute

max_images_per_prompt: int | None = Field(None, gt=0)

Maximum images per prompt.

max_pdf_size_mb class-attribute instance-attribute

max_pdf_size_mb: float | None = Field(None, gt=0)

Maximum PDF size in MB.

max_video_length class-attribute instance-attribute

max_video_length: float | None = Field(None, gt=0)

Max video length in hours.

max_videos_per_prompt class-attribute instance-attribute

max_videos_per_prompt: int | None = Field(None, gt=0)

Maximum videos per prompt.

mode instance-attribute

mode: Literal[CHAT, COMPLETION]

Model operation mode.

output_cost_per_audio_token class-attribute instance-attribute

output_cost_per_audio_token: Decimal | None = Field(None, ge=0)

Output cost per audio token.

output_cost_per_character class-attribute instance-attribute

output_cost_per_character: Decimal | None = Field(None, ge=0)

Output cost per character.

output_cost_per_character_above_128k_tokens class-attribute instance-attribute

output_cost_per_character_above_128k_tokens: Decimal | None = Field(None, ge=0)

Output cost per character above 128k tokens.

output_cost_per_image class-attribute instance-attribute

output_cost_per_image: Decimal | None = Field(None, ge=0)

Output cost per image.

output_cost_per_image_token class-attribute instance-attribute

output_cost_per_image_token: Decimal | None = Field(None, ge=0)

Output cost per image token.

output_cost_per_reasoning_token class-attribute instance-attribute

output_cost_per_reasoning_token: Decimal | None = Field(None, ge=0)

Cost per reasoning output token.

output_cost_per_second class-attribute instance-attribute

output_cost_per_second: Decimal | None = Field(None, ge=0)

Output cost per second.

output_cost_per_token_above_128k_tokens class-attribute instance-attribute

output_cost_per_token_above_128k_tokens: Decimal | None = Field(None, ge=0)

Output cost per token above 128k tokens.

output_cost_per_token_above_200k_tokens class-attribute instance-attribute

output_cost_per_token_above_200k_tokens: Decimal | None = Field(None, ge=0)

Output cost per token above 200k tokens.

output_cost_per_token_flex class-attribute instance-attribute

output_cost_per_token_flex: Decimal | None = Field(None, ge=0)

Output cost per token for flex requests.

output_cost_per_token_priority class-attribute instance-attribute

output_cost_per_token_priority: Decimal | None = Field(None, ge=0)

Output cost per token for priority requests.

output_db_cost_per_token class-attribute instance-attribute

output_db_cost_per_token: Decimal | None = Field(None, ge=0)

Output DB cost per token.

output_dbu_cost_per_token class-attribute instance-attribute

output_dbu_cost_per_token: Decimal | None = Field(None, ge=0)

Output DBU cost per token.

rpd class-attribute instance-attribute

rpd: int | None = None

Rate per day.

supported_regions class-attribute instance-attribute

supported_regions: list[SupportedRegion | str] | None = None

List of supported regions.

supports_assistant_prefill class-attribute instance-attribute

supports_assistant_prefill: bool | None = None

Whether model supports assistant prefill.

supports_audio_input class-attribute instance-attribute

supports_audio_input: bool | None = None

Whether model supports audio input.

supports_audio_output class-attribute instance-attribute

supports_audio_output: bool | None = None

Whether model supports audio output.

supports_computer_use class-attribute instance-attribute

supports_computer_use: bool | None = None

Whether model supports computer use.

supports_service_tier class-attribute instance-attribute

supports_service_tier: bool | None = None

Whether model supports service tier selection.

supports_url_context class-attribute instance-attribute

supports_url_context: bool | None = None

Whether model supports URL context.

supports_video_input class-attribute instance-attribute

supports_video_input: bool | None = None

Whether model supports video input.

vector_store_cost_per_gb_per_day class-attribute instance-attribute

vector_store_cost_per_gb_per_day: Decimal | None = Field(None, ge=0)

Vector store cost per GB per day.

:fa-brands-github: Show source on GitHub