auto-configurations/models/spring-ai-autoconfigure-model-google-genai/MIGRATION_GUIDE.md
This guide helps you migrate from the old Vertex AI-based autoconfiguration to the new Google GenAI SDK-based autoconfiguration.
Spring AI provides separate starters for Google GenAI functionality:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-google-genai</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-google-genai-embedding</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
Note: If you need both chat and embedding capabilities, include both starters in your project. The starters are designed to be used independently or together based on your requirements.
Old properties:
spring.ai.vertex.ai.gemini.project-id=my-project
spring.ai.vertex.ai.gemini.location=us-central1
spring.ai.vertex.ai.gemini.chat.options.model=gemini-pro
spring.ai.vertex.ai.embedding.text.options.model=textembedding-gecko
New properties:
# For Vertex AI mode
spring.ai.google.genai.project-id=my-project
spring.ai.google.genai.location=us-central1
spring.ai.google.genai.chat.options.model=gemini-2.0-flash
# For Gemini Developer API mode (new!)
spring.ai.google.genai.api-key=your-api-key
spring.ai.google.genai.chat.options.model=gemini-2.0-flash
# Embedding properties
spring.ai.google.genai.embedding.project-id=my-project
spring.ai.google.genai.embedding.location=us-central1
spring.ai.google.genai.embedding.text.options.model=text-embedding-004
The new SDK supports both:
transport property is no longer neededIf you were autowiring beans by name:
vertexAi → googleGenAiClientvertexAiGeminiChat → googleGenAiChatModeltextEmbedding → googleGenAiTextEmbeddingIf you were importing classes directly:
com.google.cloud.vertexai.VertexAI → com.google.genai.Clientorg.springframework.ai.vertexai.gemini.* → org.springframework.ai.google.genai.*Update your application properties:
spring.ai.vertex.ai.* with spring.ai.google.genai.*transport configurationIf using API key authentication:
spring.ai.google.genai.api-key propertyUpdate any custom configurations or bean references
Test your application thoroughly
export GOOGLE_CLOUD_PROJECT=my-project
export GOOGLE_CLOUD_LOCATION=us-central1
New (additional option):
export GOOGLE_API_KEY=your-api-key
The old autoconfiguration module is still available but deprecated. We recommend migrating to the new module as soon as possible.