Skip to content

feat: Add reasoning effort control for GPT-5 (o1 series) to AzureOpenAi properties#147

Open
caio-carne1ro wants to merge 6 commits intolangchain4j:mainfrom
caio-carne1ro:main
Open

feat: Add reasoning effort control for GPT-5 (o1 series) to AzureOpenAi properties#147
caio-carne1ro wants to merge 6 commits intolangchain4j:mainfrom
caio-carne1ro:main

Conversation

@caio-carne1ro
Copy link

Issue

Closes #4051

Change

Add support for the ReasoningEffortValue parameter in the AzureOpenAiChatModel class. This enhancement would:
Extend the AzureOpenAiChatModel.Builder to accept a reasoningEffort parameter
Store the reasoningEffort value in the model configuration
Pass the reasoningEffort value to the ChatCompletionsOptions when making API calls
Allow users to specify reasoning effort levels (LOW, MEDIUM, HIGH) for GPT-5 models
This would enable full compatibility with GPT-5 (o1 series) models and provide users with control over the reasoning compute effort.

General checklist

  • There are no breaking changes
  • I have added unit and/or integration tests for my change
  • The tests cover both positive and negative cases
  • I have manually run all the unit and integration tests in the module I have added/changed, and they are all green

Checklist for adding new Spring Boot starter

  • I have added my new starter in the root pom.xml
  • I have added a org.springframework.boot.autoconfigure.AutoConfiguration.imports file in the langchain4j-{integration}-spring-boot-starter/src/main/resources/META-INF/spring/ directory

String nonAzureApiKey,
Set<Capability> supportedCapabilities
Set<Capability> supportedCapabilities,
ReasoningEffortValue reasoningEffort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work:

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [com.azure.ai.openai.models.ReasoningEffortValue]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested, I adjusted the property to string to fix this exception

Copy link
Member

@dliubarskyi dliubarskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caio-carne1ro thanks!

@caio-carne1ro
Copy link
Author

@dliubarskyi
I'm going to start fixing this problem, but I'd like your opinion on the best approach: should I create an enum for this property in the dev.langchain4j.model.chat package?

Or should I leave it as a String for now and use a converter to ReasoningEffortValue and validate if the value is valid?

@dliubarskyi
Copy link
Member

I would just accept String reasoningEffort and then do ReasoningEffortValue.fromString(reasoningEffort) if reasoningEffort is not null/empty

@caio-carne1ro caio-carne1ro marked this pull request as ready for review January 5, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants