Add support for GPT-5.1 and GPT-5.2: update token limits and pricing

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-17 11:11:11 +00:00
parent e43f8553b6
commit 62e55389f9
7 changed files with 40 additions and 15 deletions

View File

@@ -239,8 +239,12 @@ class AICore:
'temperature': temperature,
}
# GPT-5.1 and GPT-5.2 use max_completion_tokens instead of max_tokens
if max_tokens:
body_data['max_tokens'] = max_tokens
if active_model in ['gpt-5.1', 'gpt-5.2']:
body_data['max_completion_tokens'] = max_tokens
else:
body_data['max_tokens'] = max_tokens
if response_format:
body_data['response_format'] = response_format

View File

@@ -6,6 +6,8 @@ MODEL_RATES = {
'gpt-4.1': {'input': 2.00, 'output': 8.00},
'gpt-4o-mini': {'input': 0.15, 'output': 0.60},
'gpt-4o': {'input': 2.50, 'output': 10.00},
'gpt-5.1': {'input': 1.25, 'output': 10.00},
'gpt-5.2': {'input': 1.75, 'output': 14.00},
}
# Image model pricing (per image) - EXACT from reference plugin
@@ -33,7 +35,7 @@ VALID_SIZES_BY_MODEL = {
DEFAULT_AI_MODEL = 'gpt-4.1'
# JSON mode supported models
JSON_MODE_MODELS = ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo-preview']
JSON_MODE_MODELS = ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo-preview', 'gpt-5.1', 'gpt-5.2']
# Debug mode - controls console logging
# Set to False in production to disable verbose logging

View File

@@ -99,8 +99,10 @@ def get_model_config(function_name: str, account) -> Dict[str, Any]:
# MODEL_RATES not available - skip validation
pass
# Get max_tokens and temperature from config (standardized to 8192)
max_tokens = config.get('max_tokens', 8192) # Standardized across entire codebase
# Get max_tokens and temperature from config (standardized to 8192, 16384 for GPT-5.x)
# GPT-5.1 and GPT-5.2 use 16384 max_tokens by default
default_max_tokens = 16384 if model in ['gpt-5.1', 'gpt-5.2'] else 8192
max_tokens = config.get('max_tokens', default_max_tokens)
temperature = config.get('temperature', 0.7) # Reasonable default
# Build response format based on model (JSON mode for supported models)