Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You can find more details in the [Reference Documentation](https://docs.spring.i
- [Audio Transcription](https://docs.spring.io/spring-ai/reference/api/audio/transcriptions.html)
- [Text to Speech](https://docs.spring.io/spring-ai/reference/api/audio/speech.html)
- [Moderation](https://docs.spring.io/spring-ai/reference/api/index.html#api/moderation)
- **Latest Models**: GPT-5, and other cutting-edge models for advanced AI applications.
* 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.
* [Structured Outputs](https://docs.spring.io/spring-ai/reference/api/structured-output-converter.html) - Mapping of AI Model output to POJOs.
* 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*.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,33 @@ public enum ChatModel implements ChatModelDescription {
*/
GPT_4_1("gpt-4.1"),

/**
* <b>GPT-5</b> is the next-generation flagship model with enhanced capabilities
* for complex reasoning and problem-solving tasks.
* <p>
* Note: GPT-5 models require temperature=1.0 (default value). Custom temperature
* values are not supported and will cause errors.
* <p>
* Model ID: gpt-5
* <p>
* See: <a href="https://platform.openai.com/docs/models/gpt-5">gpt-5</a>
*/
GPT_5("gpt-5"),

/**
* <b>GPT-5 (2025-08-07)</b> is a specific snapshot of the GPT-5 model from
* August 7, 2025, providing enhanced capabilities for complex reasoning and
* problem-solving tasks.
* <p>
* Note: GPT-5 models require temperature=1.0 (default value). Custom temperature
* values are not supported and will cause errors.
* <p>
* Model ID: gpt-5-2025-08-07
* <p>
* See: <a href="https://platform.openai.com/docs/models/gpt-5">gpt-5</a>
*/
GPT_5_2025_08_07("gpt-5-2025-08-07"),

/**
* <b>GPT-4o</b> (“o” for “omni”) is the versatile, high-intelligence flagship
* model. It accepts both text and image inputs, and produces text outputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import reactor.core.publisher.Flux;

import org.springframework.ai.openai.api.OpenAiApi.ChatCompletion;
Expand Down Expand Up @@ -156,4 +158,18 @@ void streamOutputAudio() {
.hasMessageContaining("400 Bad Request from POST https://api.openai.com/v1/chat/completions");
}

@ParameterizedTest(name = "{0} : {displayName}")
@EnumSource(names = {"GPT_5", "GPT_5_2025_08_07"})
void chatCompletionEntityWithNewModels(OpenAiApi.ChatModel modelName) {
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Hello world", Role.USER);
ResponseEntity<ChatCompletion> response = this.openAiApi
.chatCompletionEntity(new ChatCompletionRequest(List.of(chatCompletionMessage), modelName.getValue(), 1.0, false));

assertThat(response).isNotNull();
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().choices()).isNotEmpty();
assertThat(response.getBody().choices().get(0).message().content()).isNotEmpty();
assertThat(response.getBody().model()).containsIgnoringCase(modelName.getValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ The `JSON_SCHEMA` type enables link:https://platform.openai.com/docs/guides/stru
| spring.ai.openai.chat.options.proxy-tool-calls | If true, the Spring AI will not handle the function calls internally, but will proxy them to the client. Then is the client's responsibility to handle the function calls, dispatch them to the appropriate function, and return the results. If false (the default), the Spring AI will handle the function calls internally. Applicable only for chat models with function calling support | false
|====

[NOTE]
====
When using GPT-5 models (`gpt-5`, `gpt-5-2025-08-07`), the temperature parameter must be set to `1.0` (the default value). These models do not support custom temperature values and will return an error if any other temperature value is specified.
====

NOTE: You can override the common `spring.ai.openai.base-url` and `spring.ai.openai.api-key` for the `ChatModel` and `EmbeddingModel` implementations.
The `spring.ai.openai.chat.base-url` and `spring.ai.openai.chat.api-key` properties, if set, take precedence over the common properties.
This is useful if you want to use different OpenAI accounts for different models and different model endpoints.
Expand Down Expand Up @@ -644,4 +649,3 @@ This is useful when you need to:
* Retrieve the API key from a secure key store
* Rotate API keys dynamically
* Implement custom API key selection logic

Loading