spring-projects / spring-projects/spring-ai

[Bug] Gemini requests failed with 404 error

Open
#4,797 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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

  1. Create a new Spring Boot project (v3.5.7) using Kotlin.
  2. Add the spring-ai-starter-model-google-genai dependency at version 1.1.0-M4.
  3. Configure application.properties with the specified model:
    spring.ai.google.genai.api-key=YOUR_API_KEY_HERE
    spring.ai.google.genai.chat.options.model="gemini-2.5-flash"
    
  4. Inject the ChatClient (or ChatClient.Builder) into a service.
  5. Attempt to make any chat call, for example: chatClient.call("This is a test prompt").
  6. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.