Repository navigation
Replies: 1 comment
|
This happens because if (requestOptions.getResponseMimeType() != null) {
configBuilder.responseMimeType(requestOptions.getResponseMimeType());
}Because of that check, any empty string There are two common ways an empty string sneaks in:
Workarounds today
On the Spring AI side, changing that guard in |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Question:
responseMimeTypeis always serialized (empty) ingenerationConfigcausing INVALID_ARGUMENT error with Google Gemini APIDescription
SOS 👋,
I'm encountering an issue when using
spring-ai-google-genaiwhile calling the Google Gemini API with agenerationConfig.Specifically, when a
generationConfigis present, the fieldresponseMimeTypeis always included in the serialized JSON request, even when it is explicitly cleared or set to an empty/optional value.Example Request Payload
However, in the Spring AI client:
Even if I call something like clearResponseMimeType()
Or set it to an empty / optional value
➡️ The field still appears in the final JSON request as responseMimeType: "" whenever generationConfig exists.
This makes it impossible to send a valid request when: generationConfig is required but responseMimeType should be omitted entirely/
Expected Behavior
If responseMimeType is: null, empty or explicitly cleared
➡️ It should NOT be serialized into the request JSON at all.
In other words, the generated JSON should look like:
All reactions