You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GH-3300 | Add max_completion_tokens to Azure OpenAI configuration options
Add maxCompletionTokens support for Azure OpenAI integration
This commit implements comprehensive support for the maxCompletionTokens parameter
in the Azure OpenAI integration to enable compatibility with GPT-5 and reasoning
models (o1, o3, o4-mini series).
Key changes:
- Add maxCompletionTokens field to AzureOpenAiChatOptions with JSON serialization
- Implement builder pattern support with mutual exclusivity validation
- Add 'last-set-wins' validation logic that clears conflicting parameters with warnings
- Enhance javadoc with model-specific usage guidance for reasoning vs non-reasoning models
- Update documentation with parameter usage patterns and mutual exclusivity rules
Testing improvements:
- Add comprehensive unit tests for builder validation and mutual exclusivity scenarios
- Update integration tests to test maxTokens and maxCompletionTokens separately
- Fix test configuration to prevent default parameter conflicts
- Verify end-to-end functionality with real Azure OpenAI API calls
The implementation follows Azure OpenAI API constraints where maxTokens and
maxCompletionTokens are mutually exclusive. The validation logic prevents API
errors by automatically clearing the previously set parameter when both are
configured, with clear warning messages to guide developers.
This enables proper support for:
- Reasoning models (o1, o3, o4-mini) that require maxCompletionTokens
- Non-reasoning models (gpt-4o, gpt-3.5-turbo) that use maxTokens
- Future model compatibility without breaking changes
Signed-off-by: Oskar Drozda <[email protected]>
Signed-off-by: Mark Pollack <[email protected]>
Copy file name to clipboardExpand all lines: models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatOptions.java
+121-4Lines changed: 121 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2023-2024 the original author or authors.
2
+
* Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardExpand all lines: models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java
0 commit comments