models
Class info¶
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| ChatModel | tokonomics.models.chat_model | Clean API model for chat completion models. |
| ModelCapabilities | tokonomics.models.chat_model | Chat model capabilities and features. |
| ModelLimits | tokonomics.models.chat_model | Token and content limits for chat models. |
| ModelPricing | tokonomics.models.chat_model | Pricing information for chat models. |
🛈 DocStrings¶
Clean API models for tokonomics.
ChatModel
¶
Bases: Schema
Clean API model for chat completion models.
Source code in src/tokonomics/models/chat_model.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
from_chat_completion_model
classmethod
¶
from_chat_completion_model(name: str, model: ChatCompletionModel) -> ChatModel
Convert from internal ChatCompletionModel to clean API model.
Source code in src/tokonomics/models/chat_model.py
ModelCapabilities
¶
Bases: Schema
Chat model capabilities and features.
Source code in src/tokonomics/models/chat_model.py
supports_assistant_prefill
class-attribute
instance-attribute
¶
Whether model supports assistant prefill.
supports_audio_input
class-attribute
instance-attribute
¶
Whether model supports audio input.
supports_audio_output
class-attribute
instance-attribute
¶
Whether model supports audio output.
supports_computer_use
class-attribute
instance-attribute
¶
Whether model supports computer use.
supports_function_calling
class-attribute
instance-attribute
¶
Whether model supports function calling.
supports_parallel_function_calling
class-attribute
instance-attribute
¶
Whether model supports parallel function calling.
supports_pdf_input
class-attribute
instance-attribute
¶
Whether model supports PDF input.
supports_reasoning
class-attribute
instance-attribute
¶
Whether model supports reasoning (like o1).
supports_response_schema
class-attribute
instance-attribute
¶
Whether model supports response schema.
supports_system_messages
class-attribute
instance-attribute
¶
Whether model supports system messages.
supports_tool_choice
class-attribute
instance-attribute
¶
Whether model supports tool choice.
supports_url_context
class-attribute
instance-attribute
¶
Whether model supports URL context.
supports_video_input
class-attribute
instance-attribute
¶
Whether model supports video input.
supports_vision
class-attribute
instance-attribute
¶
Whether model supports vision/image input.
supports_web_search
class-attribute
instance-attribute
¶
Whether model supports web search.
ModelLimits
¶
Bases: Schema
Token and content limits for chat models.
Source code in src/tokonomics/models/chat_model.py
max_audio_length_hours
class-attribute
instance-attribute
¶
Maximum audio length in hours.
max_audio_per_prompt
class-attribute
instance-attribute
¶
Maximum audio files per prompt.
max_images_per_prompt
class-attribute
instance-attribute
¶
Maximum images per prompt.
max_input_tokens
class-attribute
instance-attribute
¶
Maximum input tokens supported.
max_output_tokens
class-attribute
instance-attribute
¶
Maximum output tokens supported.
max_pdf_size_mb
class-attribute
instance-attribute
¶
Maximum PDF size in MB.
max_video_length_hours
class-attribute
instance-attribute
¶
Maximum video length in hours.
max_videos_per_prompt
class-attribute
instance-attribute
¶
Maximum videos per prompt.
ModelPricing
¶
Bases: Schema
Pricing information for chat models.
Source code in src/tokonomics/models/chat_model.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
cache_creation_input_token_cost
class-attribute
instance-attribute
¶
Cost per token for cache creation.
cache_read_input_token_cost
class-attribute
instance-attribute
¶
Cost per token for cache reads.
input_cost_above_128k
class-attribute
instance-attribute
¶
Input cost per token above 128k context.
input_cost_above_200k
class-attribute
instance-attribute
¶
Input cost per token above 200k context.
input_cost_flex
class-attribute
instance-attribute
¶
Input cost per token for flex requests.
input_cost_per_audio_second
class-attribute
instance-attribute
¶
Cost per second of audio input.
input_cost_per_image
class-attribute
instance-attribute
¶
Cost per image input.
input_cost_per_token
class-attribute
instance-attribute
¶
Standard input cost per token.
input_cost_per_video_second
class-attribute
instance-attribute
¶
Cost per second of video input.
input_cost_priority
class-attribute
instance-attribute
¶
Input cost per token for priority requests.
output_cost_above_128k
class-attribute
instance-attribute
¶
Output cost per token above 128k context.
output_cost_above_200k
class-attribute
instance-attribute
¶
Output cost per token above 200k context.
output_cost_flex
class-attribute
instance-attribute
¶
Output cost per token for flex requests.
output_cost_per_reasoning_token
class-attribute
instance-attribute
¶
Cost per reasoning output token for models like o1.
output_cost_per_token
class-attribute
instance-attribute
¶
Standard output cost per token.
output_cost_priority
class-attribute
instance-attribute
¶
Output cost per token for priority requests.
tiered_pricing
class-attribute
instance-attribute
¶
tiered_pricing: list[TieredPricingTier] | None = None
Volume-based tiered pricing if available.
calculate_cost
¶
calculate_cost(
*,
input_tokens: int = 0,
cache_write_tokens: int = 0,
cache_read_tokens: int = 0,
input_audio_tokens: int = 0,
cache_audio_read_tokens: int = 0,
output_tokens: int = 0,
) -> Decimal | None
Calculate cost based on usage mirroring pydantic-ai RunUsage.
Uses contextual pricing if token count exceeds thresholds, otherwise uses standard input/output cost per token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_tokens
|
int
|
Total number of input/prompt tokens |
0
|
cache_write_tokens
|
int
|
Total number of tokens written to the cache |
0
|
cache_read_tokens
|
int
|
Total number of tokens read from the cache |
0
|
input_audio_tokens
|
int
|
Total number of audio input tokens |
0
|
cache_audio_read_tokens
|
int
|
Total number of audio tokens read from the cache |
0
|
output_tokens
|
int
|
Total number of output/completion tokens |
0
|
Returns:
| Type | Description |
|---|---|
Decimal | None
|
Total cost or None if pricing unavailable |
Source code in src/tokonomics/models/chat_model.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |