There is actually a book in the works! is writing Spring AI in Action for Manning Publications.
By using Spring AI, developers can avoid being locked into specific AI vendors. You can write your logic once and switch between providers like OpenAI , Anthropic , Microsoft , Google , or local models via Ollama just by changing configuration properties. Spring AI in Action: The Guide and Code
public record OrderDetails(String item, int quantity, String urgency) {} public OrderDetails parseOrder(String unstructuredText) var converter = new BeanOutputConverter<>(OrderDetails.class); String promptMessage = """ Extract the order information from this text: input format """; PromptTemplate template = new PromptTemplate(promptMessage); Prompt prompt = template.create(Map.of( "input", unstructuredText, "format", converter.getFormat() )); String response = chatModel.call(prompt).getResult().getOutput().getContent(); return converter.convert(response); Use code with caution. 2. Retrieval-Augmented Generation (RAG)
The full digital version of the book is officially available through . spring ai in action pdf github
Best practices illustrated by Spring-centric examples
The spring-projects/spring-ai-examples repository is the primary source. It contains boot-projects for OpenAI, Ollama, and RAG scenarios [1].
// Storing the chunks in a vector database for efficient retrieval vectorStore.add(splitDocuments); There is actually a book in the works
Use start.spring.io to generate a project, adding the OpenAI or Ollama dependency.
Setting up Maven or Gradle dependencies.
// Splitting the document into manageable chunks var textSplitter = new TokenTextSplitter(); var splitDocuments = textSplitter.split(documents); You can write your logic once and switch
Read source files (PDFs, Markdown, Word) using Spring AI's DocumentReader .
Search GitHub for the spring-attic/spring-ai-samples or community repositories featuring comprehensive sample applications. These repositories display functional implementations of multi-model pipelines, chat memories, and RAG architectures using Docker Compose to bootstrap local vector stores like Pgvector or Ollama.
Standardized APIs handle text generation, image generation, audio transcription, and vector databases.
: Early readers have awarded it a 5.0 out of 5 stars rating, citing it as the "perfect book" for bridging the gap between Java and AI engineering. GitHub & PDF Resources Spring AI in Action - Craig Walls - Manning Publications
record Actor(String name, Integer age) {}