spring-projects / spring-projects/spring-ai
[Bug] Gemini requests failed with 404 error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description
When using spring-ai-starter-model-google-genai with version 1.1.0-M4, all API requests using the GoogleGenAiChatModel fail with an HTTP 404 Not Found error.
Upon inspecting the exception, the URL being called is: https://generativelanguage.googleapis.com/v1beta/models//gemini-2.5-flash/:generateContent
There appears to be an extra forward slash (/) between /models and the model name (//gemini-2.5-flash). This malformed URL is likely causing the 404 error, as the Google API endpoint does not recognize this path.
Environment
- Spring AI Version:
1.1.0-M4 - Java Version:
21 - Spring Boot Version:
3.5.7 - Language: Kotlin
- Vector Store: None
- Chat/Embedding Model: Google Gemini (
gemini-2.5-flash)
Steps to reproduce
- Create a new Spring Boot project (
v3.5.7) using Kotlin. - Add the
spring-ai-starter-model-google-genaidependency at version1.1.0-M4. - Configure
application.propertieswith the specified model:spring.ai.google.genai.api-key=YOUR_API_KEY_HERE spring.ai.google.genai.chat.options.model="gemini-2.5-flash" - Inject the
ChatClient(orChatClient.Builder) into a service. - Attempt to make any chat call, for example:
chatClient.call("This is a test prompt"). - Observe the HTTP 404 error response from the Google API.
Expected behavior
The GoogleGenAiChatClient (or its underlying components) should construct the correct URL without the extra slash.
The expected URL should be:
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash/:generateContent
The API call should succeed (assuming a valid API key) and return a ChatResponse.
Minimal Complete Reproducible example
@RestController
@RequestMapping("/api/chat")
class ChatController(
private val chatClientBuilder: GoogleGenAiChatModel
) {
@GetMapping("")
fun chat(): Map<String, String?> {
val res = chatClientBuilder.call("Tell me who Jack Sparrow was in 30 words")
return mapOf("response" to res)
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at GoogleGenAiChatModel and the underlying Google GenAI request URL construction, then reproduce the failure with the provided Kotlin example. Verify that the generated URL has no extra slash between /models and gemini-2.5-flash, and confirm the request succeeds with a ChatResponse.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, java, kotlin, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100