@@ -30,8 +30,9 @@ from tools.public_api.models import APIStore class Grok(SerperMixin, StreamSimpleService): TOKENS_COST = { - 'grok-4.3': {'input': Decimal('875'), 'output': Decimal('1750'), 'coefficient': Decimal('5')}, + 'grok-4.3': {'input': Decimal('875'), 'output': Decimal('1750'), 'coefficient': Decimal('7')}, 'grok-4.5': {'input': Decimal('1000'), 'output': Decimal('3000'), 'coefficient': Decimal('5')}, + 'grok-4.6': {'input': Decimal('1000'), 'output': Decimal('3000'), 'coefficient': Decimal('5')}, } TOOLS_TOKEN_COSTS = {'text-embedding-3-small': {'output': Decimal('0.00001')}} @@ -194,10 +195,7 @@ class Grok(SerperMixin, StreamSimpleService): if (chunks_length := sum(len(chunk) for chunk in chunks)) > 20_000: predict_embedding_tokens = len(chunks) * 2020 predicted_input_price += ( - ( - Decimal('210') - + Decimal(chunks_length) / Decimal(len(chunks)) * Decimal('10') - ) + (Decimal('210') + Decimal(chunks_length) / Decimal(len(chunks)) * Decimal('10')) / Decimal('2.0') * self.TOKENS_COST[version]['input'] / Decimal('1_000_000') @@ -251,21 +249,14 @@ class Grok(SerperMixin, StreamSimpleService): if image: predicted_image_tokens = min((image_width * image_height + 999) // 1000, 2500) predicted_input_price += ( - Decimal(predicted_image_tokens) - * self.TOKENS_COST[version]['input'] - / Decimal('1_000_000') + Decimal(predicted_image_tokens) * self.TOKENS_COST[version]['input'] / Decimal('1_000_000') ) - estimated_input_tokens = ( - Decimal( - sum( - len(message['content']) if isinstance(message['content'], str) else 0 - for message in messages - ) - + (len(input_message.content) if image else 0) + estimated_input_tokens = Decimal( + sum( + len(message['content']) if isinstance(message['content'], str) else 0 for message in messages ) - / Decimal('2.0') - + (150 if is_free_plan else 250) - ) + + (len(input_message.content) if image else 0) + ) / Decimal('2.0') + (150 if is_free_plan else 250) predicted_input_price += ( estimated_input_tokens * self.TOKENS_COST[version]['input'] / Decimal('1_000_000') + predict_embedding_tokens * self.TOOLS_TOKEN_COSTS['text-embedding-3-small']['output'] @@ -26,6 +26,7 @@ class Qwen_3_7(StreamSimpleService): COEFFICIENT = Decimal('300.0') TOKENS_COST = { + 'qwen3.8-max': {'input': Decimal('600'), 'output': Decimal('1800')}, # $2 / $6 'qwen3.7-max': {'input': Decimal('442.5'), 'output': Decimal('1327.5')}, # $1.475 / $4.425 'qwen3.7-plus': {'input': Decimal('96'), 'output': Decimal('384')}, # $0.32 / $1.28 }