Spring AI Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation of each tool and framework before being relied on in production. This section’s bibliography lists the reference material consulted while preparing these pages. |
A single-page index of quick back-links to every page in this sub-section, grouped the same way as the sub-section itself — handy for jumping straight to the topic you need instead of paging through the full navigation. It was written against Spring AI 2.0.1, Spring Boot 4.1.x (4.1.1) and Java 21, checked on 2026-09-29; the full table is the version baseline on the landing page. Spring AI 2.0.x supports Spring Boot 4.0.x and 4.1.x and needs Java 17 or later. Its MCP Java SDK targets the 2025-11-25 revision of the MCP specification, while the rest of this site’s MCP pages are written against the 2026-07-28 revision, so the MCP box of the sheet describes the older protocol.
The downloadable PDF is a separate, single A4 page meant for printing. It states the version baseline this sub-section targets and covers:
-
the BOM and the starter naming scheme;
-
the key 2.0 properties in their flattened form, and provider selection with
spring.ai.model.*; -
ChatClientidioms: defaults, per-request options,call(),stream()andentity(); -
the advisor order constants and where memory, tool calling and validation sit in the chain;
-
@Tool,@ToolParamand the tool-callback types, and the automaticToolCallingAdvisor; -
chat memory setup with
MessageWindowChatMemory,MessageChatMemoryAdvisorand the conversation ID; -
MCP client and server properties and the
@McpTool,@McpResource,@McpPromptand@McpCompleteannotations; -
the audio APIs (
TranscriptionModel,TextToSpeechModel) and the image API (ImageModel); -
the observability metric and span names;
-
evaluator snippets with
RelevancyEvaluatorandFactCheckingEvaluator; -
Testcontainers with
@ServiceConnectionand stubbed models; -
the 1.x to 2.x renames and removed modules.
Overview — Spring AI.
Getting started — Setup & Starters.
Core API — ChatModel & ChatClient, Prompts & Templates, Chat Options, Advisors and Structured Output.
Tools and memory — Tool Calling, Tool Calling Advisor & Tool Search, Chat Memory and Chat Memory Repositories.
Streaming and MCP — Streaming & Reactive, MCP Client and MCP Server.
Multimodal and voice — Multimodality, Audio Transcription & Speech and Image Generation.
Operations and quality — Observability, Evaluation, Testing and Security & Guardrails.
Agents, local models and production — Agentic Patterns, Local Models, Production & Deployment and Migrating from 1.x to 2.x.
RAG bridge — Retrieval & RAG Bridge.
A minimal DocsAssistant chat endpoint, the idiom most of the sheet builds on (it is explained on ChatModel & ChatClient):
package com.example.docsassistant;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Service;
@Service
public class PortableDocsAssistant {
private final ChatClient chatClient;
public PortableDocsAssistant(ChatClient.Builder builder) {
this.chatClient = builder
.defaultSystem("You answer questions about the Irurueta documentation.")
.build();
}
public String ask(String question) {
return chatClient.prompt()
.user(question)
.call()
.content();
}
}
Source: Spring AI — ChatClient API.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in Spring AI’s bibliography.