DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • A Senior Engineer’s Guide to Foundry IQ, MCP, and the OpenAI Agents SDK
  • How I Built a Static Analyzer for Prompt Injection: Treating the LLM as an Untrusted Edge
  • Beyond n8n for Workflow Automation: Agent Graphs as Your Universal Agent Harness
  • Boosting React.js Development Productivity With Google Code Assist

Trending

  • Testing Async Code in Swift: Stop Using Task.yield() in Your Tests
  • Avoiding AI Debt as a Team
  • From Issue to Reviewable Patch: Build a Sandboxed Coding Agent With Deep Agents and Automated Tests
  • Data Integration Landscape 2026: Event Streaming, API, and Batch in the Era of Agentic AI

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Spring AI Migration: From the Vertex AI Gemini Module to the Google GenAI SDK

Spring AI Migration: From the Vertex AI Gemini Module to the Google GenAI SDK

The Vertex AI SDK is deprecated. Moving Spring AI to the Google GenAI SDK changes the starter, the packages, and every property key.

By 
Garima Agarwal
·
Dec. 03, 26 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
37 Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

If your Spring Boot application talks to Gemini on Google Cloud, a Spring AI migration is already on your backlog, whether you have scheduled it or not.

Google deprecated the generative AI part of the Vertex AI SDK in favor of the Google Gen AI SDK. Recent Vertex AI SDK releases print a deprecation warning in build logs, and Google has said those functions will be removed from SDK versions during 2026. At Cloud Next 2026, the Vertex AI product itself was folded into the Gemini Enterprise Agent Platform.

Spring AI followed its upstream. Spring AI 2.0 reached general availability in June 2026 and consolidated the Google providers around the Gen AI SDK. The current Spring AI reference now sends readers of the old integration to a section headed "Migration from Vertex AI Gemini," and its wording is blunt: if you were previously using spring-ai-vertex-ai-gemini, migrate to Google GenAI.

Check your own build before you plan the work. The old module was still being published as recently as the 1.1 line and the 2.0 milestones, so depending on which version you are on today, you may see a deprecation warning rather than a build failure. Either way, the destination is the same, and the sooner you move, the less you carry.

The migration is mechanical, but it touches five separate things, and two of them fail quietly rather than loudly. This article walks through each one in order.

What a Spring AI Migration Touches

Moving off the old module touches five things, and they surface at very different times.

What changes When you notice
The artifact id At build time, as a warning or a resolution failure
The package and class names At compile time
The property keys At startup, or silently as defaults
The authentication mode At the first call, as a permission error
Tool calling behavior At runtime, in a flow you may not have tested


The first two are easy, because the compiler finds them for you. The last three are the ones that cost an afternoon, so most of this article is about those.

Step 1: Swap the Dependency

Start with the build file. The chat starter changes name completely.

Replace this:

XML
 
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-vertex-ai-gemini</artifactId>
</dependency>


Add this: 

XML
 
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-google-genai</artifactId>
</dependency>


Artifact names on the Google side have shifted more than once, so search your build file for vertex rather than trusting one name. Older projects may carry spring-ai-vertex-ai-gemini-spring-boot-starter, and the manual configuration dependency spring-ai-vertex-ai-gemini may be there as well.

Note that Spring AI 2.0 targets Spring Boot 4.0 and 4.1 and moves to Jackson 3. So this is not an isolated dependency change. Plan the Spring Boot upgrade and the Spring AI upgrade as one piece of work rather than two.

Step 2: Update the Imports and Class Names

Next, fix the code. The package moved, and the client class is different.

The old code used Google's Vertex AI SDK directly:

Java
 
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatModel;
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions;
import com.google.cloud.vertexai.VertexAI;

VertexAI vertexApi = new VertexAI(projectId, location);

var chatModel = new VertexAiGeminiChatModel(vertexApi,
    VertexAiGeminiChatOptions.builder()
        .model("gemini-2.0-flash")
        .temperature(0.4)
        .build());


The new code uses the Gen AI SDK. The package is org.springframework.ai.google.genai, and the underlying client is com.google.genai.Client rather than com.google.cloud.vertexai.VertexAI.

For most applications, you will not construct the model by hand at all, because the starter auto-configures it. Therefore, the practical change in a typical Spring Boot service is deleting code rather than rewriting it. Inject ChatClient and let the starter supply the model.

Java
 
@RestController
class AnswerController {

    private final ChatClient chatClient;

    AnswerController(ChatClient.Builder builder) {
        this.chatClient = builder.build();
    }

    @GetMapping("/answer")
    String answer(@RequestParam String question) {
        return chatClient.prompt(question).call().content();
    }
}


If you do build the model manually, the embedding side has a documented equivalent. GoogleGenAiEmbeddingConnectionDetails replaces VertexAiEmbeddingConnectionDetails, and GoogleGenAiTextEmbeddingModel replaces the old embedding model class.

Step 3: Rename Every Property

This is the step that fails quietly, because an unrecognized property is usually ignored rather than rejected. Your application starts, uses defaults, and behaves differently from yesterday.

Two things changed at once. The prefix moved from spring.ai.vertex.ai.gemini to spring.ai.google.genai, and Spring AI 2.0 removed the .options segment from property keys across the whole project.

Old key New key
spring.ai.model.chat=vertexai spring.ai.model.chat=google-genai
spring.ai.vertex.ai.gemini.project-id spring.ai.google.genai.project-id
spring.ai.vertex.ai.gemini.location spring.ai.google.genai.location
spring.ai.vertex.ai.gemini.credentials-uri spring.ai.google.genai.credentials-uri
spring.ai.vertex.ai.gemini.chat.options.model spring.ai.google.genai.chat.model
spring.ai.vertex.ai.gemini.chat.options.temperature spring.ai.google.genai.chat.temperature
spring.ai.vertex.ai.gemini.chat.options.top-k spring.ai.google.genai.chat.top-k
spring.ai.vertex.ai.gemini.chat.options.max-output-tokens spring.ai.google.genai.chat.max-output-tokens


So a working configuration now looks like this:

Properties files
 
spring.ai.google.genai.project-id=my-project
spring.ai.google.genai.location=us-central1
spring.ai.google.genai.chat.model=gemini-2.5-flash
spring.ai.google.genai.chat.temperature=0.5


Watch the model default while you are here. The old module defaulted to gemini-2.0-flash and the new one defaults to gemini-2.5-flash. If you never set the model explicitly, your application changes model on upgrade without telling you. Set it explicitly either way, so the choice is recorded in your repository rather than in a release note.

Step 4: Pick Your Authentication Mode Deliberately

The new client supports two completely different backends, and one property decides which one you get.

  • Set api-key and the client calls the Gemini Developer API with that key.
  • Leave api-key unset, supply project-id and location, and the client calls Vertex AI using Google Cloud credentials.

Consequently, a team that sets both during testing will find their service account permissions ignored, because the API key wins. The symptom is a permission error that mentions the wrong project, or quota that comes off the wrong account.

For a service running on Google Cloud, you almost always want the second mode, so that the workload uses its own service account rather than a key someone pasted into a config file.

Properties files
 
# Vertex AI mode, using the workload's own credentials
spring.ai.google.genai.project-id=my-project
spring.ai.google.genai.location=us-central1


Make sure no GOOGLE_API_KEY or spring.ai.google.genai.api-key is set anywhere in the environment. Check your container image, your deployment manifest, and any .env file that gets mounted.

Step 5: Migrate Embeddings as Well

Teams usually remember the chat model and forget the embeddings, which then break at the next vector store write.

The embedding starter changes too:

XML
 
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-google-genai-embedding</artifactId>
</dependency>


The properties follow the same pattern as before, with the old spring.ai.vertex.ai.embedding prefix becoming spring.ai.google.genai.embedding: 

Properties files
 
spring.ai.model.embedding.text=google-genai
spring.ai.google.genai.embedding.project-id=my-project
spring.ai.google.genai.embedding.location=us-central1
spring.ai.google.genai.embedding.text.model=text-embedding-004
spring.ai.google.genai.embedding.text.task-type=RETRIEVAL_DOCUMENT


One important warning. If you change the embedding model or the number of dimensions during this migration, every vector already in your store becomes meaningless, because the new vectors live in a different space. So either keep the model identical, or plan a full reindex. Do not discover this from a search that quietly returns irrelevant documents.

Step 6: Check Your Tool Calling

Spring AI 2.0 also moved tool calling out of the individual chat models and into the advisor chain. A ToolCallingAdvisor is now registered automatically and runs the loop that each model used to run for itself.

For most applications this is invisible. However, if your old configuration used internal-tool-execution-enabled or the older proxy-tool-calls property to control who executes the tool, that behavior now lives somewhere else. Review any code that deliberately intercepted tool calls instead of letting the framework run them.

Therefore, the practical advice is to treat tool calling as a separate verification item rather than assuming the migration covered it.

Step 7: Verify the Spring AI Migration Before You Deploy 

Finally, prove the migration rather than assuming it. Three checks are enough.

First, confirm which model answered. The response metadata carries it:

Java
 
ChatResponse response = chatClient.prompt("hello").call().chatResponse();

System.out.println(response.getMetadata().getModel());
System.out.println(response.getMetadata().getUsage().getTotalTokens());


Second, confirm which identity made the call. Look at the Google Cloud audit logs for the request and check that the principal is the service account you expect, not a key.

Third, confirm that no property was silently dropped. Start the application with the failure switch on so unknown keys are reported instead of ignored:

Shell
 
java -jar app.jar --spring.config.ignore-unknown-properties=false


Run that once in a staging environment. It is the fastest way to find a spring.ai.vertex.ai.gemini.* key that somebody left in a profile file.

Conclusion

This Spring AI migration is unusual in that it comes from two directions at once. Google deprecated the generative AI part of the Vertex AI SDK in favor of the Gen AI SDK, and Spring AI consolidated its Google support around the same SDK. Neither direction is going to reverse, so the old path has no future, even where it still resolves today.

The work itself is a few hours. Swap the starter, fix the imports, rename the properties, decide your authentication mode on purpose, migrate the embeddings, and check tool calling. The parts that cost teams a day are the quiet ones: a renamed property that defaults instead of failing, a stray API key that overrides the service account, and an embedding model change that invalidates an existing index.

Do those three checks and the rest is straightforward.

Further Reading

  • Google GenAI Chat, Spring AI Reference
  • Google GenAI Text Embeddings, Spring AI Reference
  • Spring AI 2.0.0 GA announcement
  • Gemini Enterprise Agent Platform release notes
AI Software development kit Google (verb)

Opinions expressed by DZone contributors are their own.

Related

  • A Senior Engineer’s Guide to Foundry IQ, MCP, and the OpenAI Agents SDK
  • How I Built a Static Analyzer for Prompt Injection: Treating the LLM as an Untrusted Edge
  • Beyond n8n for Workflow Automation: Agent Graphs as Your Universal Agent Harness
  • Boosting React.js Development Productivity With Google Code Assist

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook