Skip to content

Commit dd3afa1

Browse files
Claudeowndev
andcommitted
Add GPT-4o model detection for max_completion_tokens conversion
GPT-4o models (gpt-4o, gpt-4o-mini, gpt-4o-2024-*, etc.) also require max_completion_tokens instead of max_tokens. Updated _is_new_generation_model() to detect all GPT-4o variants. Fixes: "Unsupported parameter: 'max_tokens' is not supported with this model" Co-authored-by: owndev <69784886+owndev@users.noreply.github.com>
1 parent b30bed7 commit dd3afa1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pipelines/azure/azure_ai_foundry.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,11 +1489,11 @@ def _is_new_generation_model(self, model_name: str) -> bool:
14891489
"""
14901490
Determine if a model requires max_completion_tokens instead of max_tokens.
14911491
1492-
GPT-5, o-series (o1, o3, o4), and reasoning models use max_completion_tokens
1492+
GPT-4o, GPT-5, o-series (o1, o3, o4), and reasoning models use max_completion_tokens
14931493
to distinguish between internal reasoning tokens and output completion tokens.
14941494
14951495
Args:
1496-
model_name: The model identifier (e.g., "gpt-5", "o1", "gpt-4")
1496+
model_name: The model identifier (e.g., "gpt-4o", "gpt-5", "o1", "gpt-4")
14971497
14981498
Returns:
14991499
True if the model requires max_completion_tokens, False otherwise
@@ -1503,6 +1503,10 @@ def _is_new_generation_model(self, model_name: str) -> bool:
15031503

15041504
model_lower = model_name.lower()
15051505

1506+
# GPT-4o series models (gpt-4o, gpt-4o-mini, gpt-4o-2024-*, gpt-4o-realtime-preview, etc.)
1507+
if "gpt-4o" in model_lower or model_lower.startswith("gpt-4o"):
1508+
return True
1509+
15061510
# GPT-5 series models
15071511
if model_lower.startswith("gpt-5") or model_lower.startswith("gpt‑5"):
15081512
return True

0 commit comments

Comments
 (0)