Skip to content

Commit 7362deb

Browse files
committed
feat: add GPT-5 model enum support and update documentation
- Add GPT_5 and GPT_5_2025_08_07 enum constants to ChatModel in OpenAiApi.java - Update OpenAiApiIT test to use enum constants instead of hardcoded strings - Enhance README.md to highlight support for latest models including GPT-5 - Include JavaDoc documentation with temperature requirement notes (1.0) Fixes GPT-5 model integration with proper type-safe enum constants
1 parent 0b7318f commit 7362deb

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can find more details in the [Reference Documentation](https://docs.spring.i
2323
- [Audio Transcription](https://docs.spring.io/spring-ai/reference/api/audio/transcriptions.html)
2424
- [Text to Speech](https://docs.spring.io/spring-ai/reference/api/audio/speech.html)
2525
- [Moderation](https://docs.spring.io/spring-ai/reference/api/index.html#api/moderation)
26+
- **Latest Models**: GPT-5, and other cutting-edge models for advanced AI applications.
2627
* Portable API support across AI providers for both synchronous and streaming options. Access to [model-specific features](https://docs.spring.io/spring-ai/reference/api/chatmodel.html#_chat_options) is also available.
2728
* [Structured Outputs](https://docs.spring.io/spring-ai/reference/api/structured-output-converter.html) - Mapping of AI Model output to POJOs.
2829
* Support for all major [Vector Database providers](https://docs.spring.io/spring-ai/reference/api/vectordbs.html) such as *Apache Cassandra, Azure Vector Search, Chroma, Elasticsearch, Milvus, MongoDB Atlas, MariaDB, Neo4j, Oracle, PostgreSQL/PGVector, PineCone, Qdrant, Redis, and Weaviate*.

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiApi.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,33 @@ public enum ChatModel implements ChatModelDescription {
468468
*/
469469
GPT_4_1("gpt-4.1"),
470470

471+
/**
472+
* <b>GPT-5</b> is the next-generation flagship model with enhanced capabilities
473+
* for complex reasoning and problem-solving tasks.
474+
* <p>
475+
* Note: GPT-5 models require temperature=1.0 (default value). Custom temperature
476+
* values are not supported and will cause errors.
477+
* <p>
478+
* Model ID: gpt-5
479+
* <p>
480+
* See: <a href="https://platform.openai.com/docs/models/gpt-5">gpt-5</a>
481+
*/
482+
GPT_5("gpt-5"),
483+
484+
/**
485+
* <b>GPT-5 (2025-08-07)</b> is a specific snapshot of the GPT-5 model from
486+
* August 7, 2025, providing enhanced capabilities for complex reasoning and
487+
* problem-solving tasks.
488+
* <p>
489+
* Note: GPT-5 models require temperature=1.0 (default value). Custom temperature
490+
* values are not supported and will cause errors.
491+
* <p>
492+
* Model ID: gpt-5-2025-08-07
493+
* <p>
494+
* See: <a href="https://platform.openai.com/docs/models/gpt-5">gpt-5</a>
495+
*/
496+
GPT_5_2025_08_07("gpt-5-2025-08-07"),
497+
471498
/**
472499
* <b>GPT-4o</b> (“o” for “omni”) is the versatile, high-intelligence flagship
473500
* model. It accepts both text and image inputs, and produces text outputs

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/api/OpenAiApiIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2626
import org.junit.jupiter.params.ParameterizedTest;
27-
import org.junit.jupiter.params.provider.ValueSource;
27+
import org.junit.jupiter.params.provider.EnumSource;
2828
import reactor.core.publisher.Flux;
2929

3030
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletion;
@@ -159,17 +159,17 @@ void streamOutputAudio() {
159159
}
160160

161161
@ParameterizedTest(name = "{0} : {displayName}")
162-
@ValueSource(strings = { "gpt-5", "gpt-5-2025-08-07" })
163-
void chatCompletionEntityWithNewModels(String modelName) {
162+
@EnumSource(names = {"GPT_5", "GPT_5_2025_08_07"})
163+
void chatCompletionEntityWithNewModels(OpenAiApi.ChatModel modelName) {
164164
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Hello world", Role.USER);
165165
ResponseEntity<ChatCompletion> response = this.openAiApi
166-
.chatCompletionEntity(new ChatCompletionRequest(List.of(chatCompletionMessage), modelName, 1.0, false));
166+
.chatCompletionEntity(new ChatCompletionRequest(List.of(chatCompletionMessage), modelName.getValue(), 1.0, false));
167167

168168
assertThat(response).isNotNull();
169169
assertThat(response.getBody()).isNotNull();
170170
assertThat(response.getBody().choices()).isNotEmpty();
171171
assertThat(response.getBody().choices().get(0).message().content()).isNotEmpty();
172-
assertThat(response.getBody().model()).containsIgnoringCase(modelName);
172+
assertThat(response.getBody().model()).containsIgnoringCase(modelName.getValue());
173173
}
174174

175175
}

0 commit comments

Comments
 (0)