Spring AI 1.1

When upgrading to Spring AI 1.1, refer to the Upgrade Notes to find out about newly introduced APIs, deprecated APIs, and information about breaking changes.

The io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_1 recipe automates many of the changes introduced in Spring AI 1.1.0. You can use it to update your project to the latest Spring AI 1.1.x release.

The recipe will:

  • Upgrade all org.springframework.ai dependencies to the 1.1.x release line.

  • Rename Spring AI configuration properties to match the new property names.

  • Migrate to the new AssistantMessage, EmbeddingOptions, QuestionAnswerAdvisor, and ToolResponseMessage builders.

  • For Bedrock: rename BedrockTitanEmbeddingOptions.Builder.withInputType(…​) to inputType(…​).

  • For Text-to-Speech: move the speech model types from org.springframework.ai.openai.audio.speech to the new vendor-agnostic org.springframework.ai.audio.tts package, renaming SpeechMessageTextToSpeechMessage, SpeechModelTextToSpeechModel, SpeechPromptTextToSpeechPrompt, SpeechResponseTextToSpeechResponse, and StreamingSpeechModelStreamingTextToSpeechModel.

  • For MCP (Model Context Protocol): rename spring-ai-autoconfigure-mcp-client and spring-ai-autoconfigure-mcp-server to add the -common suffix; automatically add the transport-specific autoconfigure dependencies (spring-ai-autoconfigure-mcp-{client-{httpclient,webflux},server-{webflux,webmvc}}) when the corresponding autoconfiguration types are used; relocate the MCP client autoconfigure types from org.springframework.ai.mcp.client.autoconfigure to org.springframework.ai.mcp.client.common.autoconfigure (and the transport-specific types to their respective httpclient / webflux sub-packages); move server autoconfigure types under org.springframework.ai.mcp.server.common.autoconfigure; and rename McpWebFluxServerAutoConfiguration and McpWebMvcServerAutoConfiguration to McpServerSseWebFluxAutoConfiguration and McpServerSseWebMvcAutoConfiguration.

Run the recipe

You can apply this recipe with any OpenRewrite-compatible tool. The tabs below show three of them: the Arconia CLI, the OpenRewrite Gradle plugin, and the OpenRewrite Maven plugin. See Running Recipes for a comparison of when to pick each one.

  • Arconia CLI

  • Gradle

  • Maven

arconia update spring-ai --to-version=1.1

First, create an init.gradle file in your project root with the following content.

initscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2" }
    }
    dependencies {
        classpath("org.openrewrite:plugin:latest.release")
    }
}

rootProject {
    plugins.apply(org.openrewrite.gradle.RewritePlugin)
    dependencies {
        rewrite("io.arconia.migrations:rewrite-spring:latest.release")
    }

    afterEvaluate {
        if (repositories.isEmpty()) {
            repositories {
                mavenCentral()
            }
        }
    }

    configurations.named("rewrite") {
        canBeConsumed = false
    }
}

Then, run the following command.

./gradlew rewriteRun \
    --init-script init.gradle \
    -DactiveRecipe=io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_1

You can remove the init.gradle file afterwards.

./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=io.arconia.migrations:rewrite-spring:LATEST \
  -Drewrite.activeRecipes=io.arconia.rewrite.spring.ai.UpgradeSpringAi_1_1