@@ -60,7 +60,7 @@ from ml_model.services.pulid import Pulid from ml_model.services.qwen import Qwen from ml_model.services.qwen_235B import Qwen_235B from ml_model.services.qwen_3_6 import Qwen_3_6 -from ml_model.services.qwen_3_7 import Qwen_3_7 +from ml_model.services.qwen_3_8 import Qwen_3_8 from ml_model.services.qwen_3_max_thinking import Qwen_3_Max_Thinking from ml_model.services.raifgpt import Raifgpt from ml_model.services.ray import Ray @@ -32,6 +32,7 @@ class Grok(SerperMixin, StreamSimpleService): TOKENS_COST = { 'grok-4.3': {'input': Decimal('875'), 'output': Decimal('1750'), 'coefficient': Decimal('5')}, 'grok-4.5': {'input': Decimal('1000'), 'output': Decimal('3000'), 'coefficient': Decimal('5')}, + 'grok-4.6': {'input': Decimal('600'), 'output': Decimal('1800'), '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'] @@ -22,15 +22,16 @@ from tools.copywrite.models import Copywrite from tools.public_api.models import APIStore -class Qwen_3_7(StreamSimpleService): +class Qwen_3_8(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 } - MAX_OUTPUT_TOKENS = 30_000 + MAX_OUTPUT_TOKENS = 131_072 // 2 TOOLS_TOKEN_COSTS = {'text-embedding-3-small': {'output': Decimal('0.00001')}} @@ -80,7 +81,7 @@ class Qwen_3_7(StreamSimpleService): version_slug, model_slug, callback_data, messages, embedding_tokens = self._prepare_data( input_message ) - result = openrouter_run(model_slug, messages, callback_data, 'Qwen 3.7') + result = openrouter_run(model_slug, messages, callback_data, 'Qwen 3.8') process_time = timedelta(seconds=(time.time() - start_time)) self.handle_invoice( input_message.content_object.model, @@ -245,7 +245,7 @@ def openrouter_run(version: str, messages: list, callback_data: dict, model_name logger.error(f'Model {model_name} disabled') raise DeploymentDisabled else: - if re.match(r'^qwen/qwen3\.7-.*$', data['model']): + if re.match(r'^qwen/qwen3\.[78]-.*$', data['model']): input_tokens = data['usage']['cost'] output_tokens = 0 else: