From f9178e947e36a52bf65678b546b1ec0701d0d78f Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Thu, 16 Apr 2026 16:21:16 -0300 Subject: [PATCH] Use max_completion_tokens for GPT-5 models --- src/llm/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/llm/mod.rs b/src/llm/mod.rs index 012db11e..0f5967c6 100644 --- a/src/llm/mod.rs +++ b/src/llm/mod.rs @@ -506,11 +506,17 @@ impl LLMProvider for OpenAIClient { } // Build the request body - include tools if provided + // GPT-5 models use max_completion_tokens instead of max_tokens + let token_key = if model.contains("gpt-5") { + "max_completion_tokens" + } else { + "max_tokens" + }; let mut request_body = serde_json::json!({ "model": model, "messages": messages, "stream": true, - "max_tokens": 16384, + token_key: 16384, "temperature": 1.0, "top_p": 1.0 });