-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
After updating the Azure OpenAI model configuration from gpt-4 to a gpt-5 deployment, the application fails when making calls to the model. The API returns an InvalidRequestException stating that the max_tokens parameter is not supported and that max_completion_tokens should be used instead. This suggests that the Semantic Kernel library is sending an outdated parameter name that is incompatible with the new model version.
To Reproduce
Configure the application to use an Azure OpenAI deployment of the gpt-5 model.
Add logging to the kernel builder.
builder.Services.AddLogging(logging =>
{
logging.AddConsole();
logging.AddDebug();
logging.SetMinimumLevel(LogLevel.Trace);
});
Execute a kernel call using InvokePromptAsync, explicitly setting the MaxTokens property within the OpenAIPromptExecutionSettings as shown below:
C#
var result = await _kernel.InvokePromptAsync(prompt, new KernelArguments(new OpenAIPromptExecutionSettings
{
MaxTokens = 400,
Temperature = 0.3
}));
Observe the application throwing a Microsoft.SemanticKernel.Http.HttpOperationException in the Debug Output window.
Expected behavior
The call to the gpt-5 model should execute successfully. It's expected that the Semantic Kernel library would either abstract away this parameter name change or provide a clear configuration path in PromptExecutionSettings to use max_completion_tokens without causing the application to crash.
Platform
Language: C#
Source: Microsoft.SemanticKernel NuGet package version 1.61.0
AI model: Azure OpenAI: gpt-5 (and model-selector)
IDE: Visual Studio 2022
OS: Windows 11