---
title: "Introduction to Google GenAI Chat and Spring AI"
url: https://daily.dev/posts/introduction-to-google-genai-chat-and-spring-ai-h3wj5zlvx
source_url: https://feeds.feedblitz.com/~/967131092/0/baeldung
type: article
source: "Baeldung"
published: 2026-08-07T03:36:28.832Z
updated: 2026-08-07T03:37:19.311Z
tags: ["java", "spring", "spring-boot", "google-gemini", "spring-ai"]
reading_time: 9
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to Google GenAI Chat and Spring AI

**[Baeldung](https://daily.dev/sources/baeldung)** · 9 min read · 1 upvotes · 0 comments

## Summary

A step-by-step guide to integrating Google's Gemini models into a Spring Boot application using Spring AI's `spring-ai-starter-model-google-genai` module. Covers Maven setup with Spring AI BOM 2.0.0, explicit chat provider activation via `spring.ai.model.chat=google-genai`, and two abstraction layers: the low-level `GoogleGenAiChatModel` and the fluent `ChatClient` API. Also demonstrates prompt templates for dynamic inputs, live Google Search grounding to reduce hallucinations, reactive token streaming with WebFlux `Flux<String>`, and MockMvc-based unit testing that avoids real API calls.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://feeds.feedblitz.com/~/967131092/0/baeldung>

## Questions this post answers

### How do I activate the Google GenAI chat provider in Spring AI without it auto-configuring from the classpath?

You must explicitly set `spring.ai.model.chat=google-genai` in your `application.properties`. In recent Spring AI versions, adding a starter to the classpath no longer auto-activates it, preventing conflicts when multiple LLM providers are present. You also need `spring.ai.google.genai.chat.model=gemini-2.5-flash` and `spring.ai.google.genai.api-key` pointing to your Google AI Studio key.

_Java developers wiring up multiple LLM providers track Spring AI configuration changes like this on daily.dev._

### How do I enable live Google Search grounding in Spring AI with the Google GenAI module?

Set `spring.ai.google.genai.chat.google-search-retrieval=true` in your `application.properties`. With this flag enabled, queries about current events are automatically grounded using live Google Search results, reducing hallucinations caused by the model's training cutoff. No code changes to the `ChatClient` call chain are required — the grounding is applied globally at the configuration level.

_Developers building real-time Q&A features on Gemini find the latest Spring AI grounding updates on daily.dev._

### How do I stream Gemini responses token by token in a Spring Boot application using Spring AI?

Return a `Flux<String>` from your service by calling `.stream().content()` on the `ChatClient` prompt chain. In the controller, annotate the endpoint with `produces = MediaType.TEXT_EVENT_STREAM_VALUE` to deliver tokens as Server-Sent Events. Spring Boot's WebFlux integration handles the non-blocking pipeline, sending each token chunk to the client as it arrives rather than waiting for the full response.

_Teams reducing perceived latency in AI chat UIs follow Spring AI streaming patterns on daily.dev._

---

Tags: [#java](https://daily.dev/tags/java), [#spring](https://daily.dev/tags/spring), [#spring-boot](https://daily.dev/tags/spring-boot), [#google-gemini](https://daily.dev/tags/google-gemini), [#spring-ai](https://daily.dev/tags/spring-ai)

[View this post on daily.dev](https://daily.dev/posts/introduction-to-google-genai-chat-and-spring-ai-h3wj5zlvx)
