@@ -168,6 +168,9 @@ class Products(BaseModel):
168168 llm_tokens : Product = Field (
169169 description = "LLM token quota to this plan or tier." ,
170170 )
171+ image_tokens : Product = Field (
172+ description = "Image token quota to this plan or tier." ,
173+ )
171174 embedding_tokens : Product = Field (
172175 description = "Embedding token quota to this plan or tier." ,
173176 )
@@ -188,6 +191,7 @@ class Products(BaseModel):
188191 def null (cls ):
189192 return cls (
190193 llm_tokens = Product .null ("ELLM tokens" , "Million Tokens" ),
194+ image_tokens = Product .null ("Image tokens" , "Million Tokens" ),
191195 embedding_tokens = Product .null ("Embedding tokens" , "Million Tokens" ),
192196 reranker_searches = Product .null ("Reranker searches" , "Thousand Searches" ),
193197 db_storage = Product .null ("Database storage" , "GiB" ),
@@ -199,6 +203,7 @@ def null(cls):
199203 def unlimited (cls , unit_cost : float = 0.0 ):
200204 return cls (
201205 llm_tokens = Product .unlimited ("ELLM tokens" , "Million Tokens" , unit_cost ),
206+ image_tokens = Product .unlimited ("Image tokens" , "Million Tokens" , unit_cost ),
202207 embedding_tokens = Product .unlimited ("Embedding tokens" , "Million Tokens" , unit_cost ),
203208 reranker_searches = Product .unlimited (
204209 "Reranker searches" , "Thousand Searches" , unit_cost
@@ -213,6 +218,7 @@ def unlimited(cls, unit_cost: float = 0.0):
213218 credit = ("credit" ,),
214219 credit_grant = ("credit_grant" ,),
215220 llm_tokens = ("llm_tokens_quota_mtok" , "llm_tokens_usage_mtok" ),
221+ image_tokens = ("image_tokens_quota_mtok" , "image_tokens_usage_mtok" ),
216222 embedding_tokens = (
217223 "embedding_tokens_quota_mtok" ,
218224 "embedding_tokens_usage_mtok" ,
@@ -228,6 +234,7 @@ class ProductType(StrEnum):
228234 CREDIT = "credit"
229235 CREDIT_GRANT = "credit_grant"
230236 LLM_TOKENS = "llm_tokens"
237+ IMAGE_TOKENS = "image_tokens"
231238 EMBEDDING_TOKENS = "embedding_tokens"
232239 RERANKER_SEARCHES = "reranker_searches"
233240 DB_STORAGE = "db_storage"
@@ -308,6 +315,12 @@ def free(
308315 tiers = [],
309316 unit = "Million Tokens" ,
310317 ),
318+ image_tokens = Product (
319+ name = "Image tokens" ,
320+ included = PriceTier (unit_cost = 0.5 , up_to = 0.75 ),
321+ tiers = [],
322+ unit = "Million Tokens" ,
323+ ),
311324 embedding_tokens = Product (
312325 name = "Embedding tokens" ,
313326 included = PriceTier (unit_cost = 0.5 , up_to = 0.75 ),
@@ -514,6 +527,7 @@ def status(self) -> str:
514527class ModelType (StrEnum ):
515528 COMPLETION = "completion"
516529 LLM = "llm"
530+ IMAGE_GEN = "image_gen"
517531 EMBED = "embed"
518532 RERANK = "rerank"
519533
@@ -527,6 +541,7 @@ class ModelCapability(StrEnum):
527541 CHAT = "chat"
528542 TOOL = "tool"
529543 IMAGE = "image" # TODO: Maybe change to "image_in" & "image_out"
544+ IMAGE_OUT = "image_out"
530545 AUDIO = "audio"
531546 EMBED = "embed"
532547 RERANK = "rerank"
@@ -548,7 +563,7 @@ class ModelInfo(_BaseModel):
548563 )
549564 type : _ModelType = Field (
550565 "" ,
551- description = "Model type. Can be completion, llm, embed, or rerank." ,
566+ description = "Model type. Can be completion, llm, image_gen, embed, or rerank." ,
552567 examples = [ModelType .LLM ],
553568 )
554569 name : SanitisedNonEmptyStr = Field (
@@ -645,6 +660,15 @@ class ModelConfigUpdate(ModelInfo):
645660 - 1.0 ,
646661 description = "Cost in USD per million (mega) output / completion token." ,
647662 )
663+ # --- Image generation models --- #
664+ image_input_cost_per_mtoken : float = Field (
665+ - 1.0 ,
666+ description = "Cost in USD per million (mega) image input tokens." ,
667+ )
668+ image_output_cost_per_mtoken : float = Field (
669+ - 1.0 ,
670+ description = "Cost in USD per million (mega) image output tokens." ,
671+ )
648672 # --- Embedding models --- #
649673 embedding_size : PositiveNonZeroInt | None = Field (
650674 None ,
@@ -703,6 +727,14 @@ def check_chat_cost_per_mtoken(self) -> Self:
703727 self .llm_output_cost_per_mtoken = 0.600
704728 return self
705729
730+ @model_validator (mode = "after" )
731+ def check_image_cost_per_mtoken (self ) -> Self :
732+ if self .image_input_cost_per_mtoken < 0 :
733+ self .image_input_cost_per_mtoken = 0.0
734+ if self .image_output_cost_per_mtoken < 0 :
735+ self .image_output_cost_per_mtoken = 0.0
736+ return self
737+
706738 @model_validator (mode = "after" )
707739 def check_embed_cost_per_mtoken (self ) -> Self :
708740 # OpenAI text-embedding-3-small pricing (2024-09-09)
@@ -729,7 +761,7 @@ class ModelConfigCreate(ModelConfigUpdate):
729761 ),
730762 )
731763 type : _ModelType = Field (
732- description = "Model type. Can be completion, llm, embed, or rerank." ,
764+ description = "Model type. Can be completion, llm, image_gen, embed, or rerank." ,
733765 )
734766 name : SanitisedNonEmptyStr = Field (
735767 max_length = 255 ,
@@ -1087,6 +1119,12 @@ class Organization_(OrganizationCreate, _TableBase):
10871119 llm_tokens_usage_mtok : float = Field (
10881120 description = "LLM token usage in millions of tokens." ,
10891121 )
1122+ image_tokens_quota_mtok : float | None = Field (
1123+ description = "Image token quota in millions of tokens." ,
1124+ )
1125+ image_tokens_usage_mtok : float = Field (
1126+ description = "Image token usage in millions of tokens." ,
1127+ )
10901128 embedding_tokens_quota_mtok : float | None = Field (
10911129 description = "Embedding token quota in millions of tokens." ,
10921130 )
0 commit comments