What you will learn in Spring AI in Action
Chapter by chapter
Chapter 1: Getting started with Spring AI
The introduction explains what generative AI offers users and developers, and why Spring AI makes it accessible in Java applications.
What you learn in chapter 1 →Chapter 2: Evaluating generated responses
This introduction explains why ordinary assertions and mocked responses cannot fully test generative AI behavior, then introduces Spring AI evaluators as a way to judge generated answers.
What you learn in chapter 2 →Chapter 3: Submitting prompts for generation
The chapter introduction explains why more advanced Spring AI applications may need richer prompt and response handling than simple strings.
What you learn in chapter 3 →Chapter 4: Talking with your documents
The introduction explains why giving an LLM relevant document content when a question is asked can improve answers beyond what its training alone supports.
What you learn in chapter 4 →Chapter 5: Enabling conversational memory
This introduction explains why an LLM’s lack of memory makes follow-up conversation difficult.
What you learn in chapter 5 →Chapter 6: Activating tool-driven generation
The introduction explains why an LLM may need tools to obtain real-time information that training and RAG cannot supply.
What you learn in chapter 6 →Chapter 7: Applying Model Context Protocol
Introduces MCP as a way to package related tools for sharing across AI applications, in contrast to coding tools into one Spring AI application.
What you learn in chapter 7 →Chapter 8: Generating with voice and pictures
The introduction explains why moving beyond text-only interaction would make Board Game Buddy more natural for people to use.
What you learn in chapter 8 →Chapter 9: Observing AI operations
The introduction explains why observing application metrics and tracing data helps reveal the health and behavior of a Spring AI application.
What you learn in chapter 9 →Chapter 10: Safeguarding generative AI
The introduction explains why generative AI applications must protect access to documents and tools and guard against prompts that elicit sensitive responses.
What you learn in chapter 10 →Chapter 11: Applying generative AI patterns
This introduction explains that Spring AI’s ChatClient can do more than answer questions, with the task shaped largely by the prompt.
What you learn in chapter 11 →Chapter 12: Employing agents
Introduces generative AI agents as goal-oriented actors while noting that their precise definition is debated.
What you learn in chapter 12 →Concepts explained in this book
- Spring AISpring AI is a Java library that provides abstractions and integrations for incorporating generative AI capabilities into Spring applications.
- MCP serverAn MCP server is an application component that communicates through the Model Context Protocol to expose capabilities or contextual information to an MCP client.
- vector databaseA vector store is a data store that indexes numerical vector representations and supports similarity-based retrieval of associated items such as documents.
- templateA prompt template is a reusable prompt structure containing static text and placeholders that are filled with varying model data.
- toolA tool is a callable capability that allows an AI model or application to obtain data or perform an action through external functionality.
- text chunkA document splitter divides a document into smaller chunks suitable for downstream processing.
- @Action@Action is an Embabel annotation that marks a method as an action available for workflow planning or execution.
- pipelineA workflow is an explicitly defined sequence of operations that coordinates application processing steps.
- promptA prompt is input supplied to a language model to elicit a generated response, potentially including text and image context.
- EmbabelEmbabel is a framework for building software agents that can perform goal-directed tasks using language models and external capabilities.
- retrieval-augmented generationRetrieval-augmented generation is a technique that supplies retrieved external information to a generative model when producing a response.
- @Agent@Agent is an Embabel annotation that declares a class to be an agent and can assign it identifying metadata.
- stdio transportSTDIO transport is a process communication method that exchanges data through a program's standard input and standard output streams, including for MCP client-server communication.
- messagewindowchatmemoryMessageWindowChatMemory is a Spring AI chat-memory implementation that maintains a bounded window of conversational messages through a ChatMemoryRepository.
- Spring AI OpenAI starterThe Spring AI OpenAI integration is the Spring AI module that connects applications to OpenAI models and services.
- PrometheusPrometheus is an open-source monitoring system that collects and stores time-series metrics and supports querying and alerting.
- chatmemoryrepositoryChatMemoryRepository is an abstraction for storing and retrieving chat history used by chat-memory implementations.
- Spring AI Tika Document ReaderTikaDocumentReader is a Spring AI document reader that uses Apache Tika to read many document formats.
- mcp clientAn MCP client is an application component that connects to an MCP server and invokes capabilities exposed through the Model Context Protocol.
- http+sse transportAn HTTP+SSE client transport is a communication transport that uses HTTP and Server-Sent Events for an MCP client connection.
- advisorCallAdvisor is a Spring AI advisor interface for inspecting and modifying a language-model request before execution and its response before return.
- ChatClientChatClient is a Spring AI API component for sending conversational requests to language models and receiving responses.
- TokenTextSplitterTokenTextSplitter is a Spring AI document splitter that divides text into token-bounded chunks while avoiding mid-sentence splits.
- language modelA large language model is a machine-learning model trained on extensive text data to understand and generate natural-language content.
- @Tool annotationThe @Tool annotation marks a method as a callable tool that an AI application can expose to a language model.
- token countToken usage is the measured quantity of input and output tokens consumed during a language-model interaction.
- top-k samplingTop-k is a language-model generation parameter that limits token candidates to a specified count of the highest-probability tokens.
- fileSupplierfileSupplier is a Spring Function Catalog function that monitors a directory for new files and emits them to a consumer.
- GPT-4o-miniGPT-4o mini Audio is an OpenAI audio-capable model variant optimized for lower-cost multimodal generation.
- authorizationAuthorization is the determination of whether an authenticated subject has permission to perform a requested operation or access a resource.
- MessageChatMemoryAdvisorA chat memory advisor is a Spring AI advisor that manages conversational memory by supplying prior dialogue to later language-model prompts.
- ImageOptionsImageOptions is a Spring AI options object that specifies parameters controlling image generation, such as dimensions and response format.
- metric endpointA metrics endpoint is an HTTP endpoint that exposes named application measurements and their associated statistics and tags.
- RetrievalAugmentationAdvisorRetrievalAugmentationAdvisor is a Spring AI advisor that assembles retrieved document context into a language-model interaction through configurable retrieval and processing components.
- Spring SecuritySpring Security is a Spring framework project that provides authentication, authorization, and protection against common application security threats.
- Spring Boot ActuatorSpring Boot Actuator is a Spring Boot module that provides production-oriented monitoring and management endpoints for an application.
- media()media() is a Spring AI user-message specification method that attaches media content and its MIME type to a prompt.
- MCP resourceAn MCP resource is a named, described, URI-addressable source of contextual content exposed through the Model Context Protocol.
- ToolCallbackProviderToolCallbackProvider is a Spring AI provider that supplies callbacks representing callable tools to an MCP integration.
- adversarial promptMalicious prompting is the deliberate crafting of prompts to make a generative AI application produce harmful, unauthorized, or prohibited behavior.
- image generationImage generation is the production of images by an AI model from textual or other input specifications.
- premium contentPremium content is document content whose access is restricted to users with premium authorization.
- Spring Function CatalogFunctionCatalog is a Spring Cloud Function registry for discovering and retrieving function beans by name.
- MCPThe Model Context Protocol is an open protocol for connecting AI applications with external tools and sources of contextual information.
- QdrantQdrant is a vector database for storing, filtering, and similarity-searching vector data and its associated payloads.
- ImageModelImageModel is a Spring AI interface for generating images through provider-specific implementations.
- RESTA REST service is a network service that exposes functionality or resources through REST-style HTTP endpoints.
- CassandraChatMemoryRepositoryCassandraChatMemoryRepository is a Spring AI ChatMemoryRepository implementation that persists chat history in Apache Cassandra.
- JdbcChatMemoryRepositoryJdbcChatMemoryRepository is a Spring AI ChatMemoryRepository implementation that persists chat history through JDBC in a relational database.
- Neo4jChatMemoryRepositoryNeo4jChatMemoryRepository is a Spring AI ChatMemoryRepository implementation that persists chat history in Neo4j.
- JaegerJaeger is an open-source distributed-tracing system for collecting, storing, and visualizing trace data.
- Docker Compose supportDocker Compose support is a Spring Boot capability that manages containers defined in a Docker Compose configuration during application startup and shutdown.
- defaultOptions()defaultOptions() is a ChatClient builder method that specifies default chat options for requests created by the client.
- temperatureTemperature is a language-model generation parameter from 0 to 2 that scales token probabilities to control response randomness.
- top-p filteringTop-p is a language-model generation parameter from 0 to 1 that limits token candidates to the smallest probability set whose cumulative probability reaches the parameter value.
- Micrometer TracingMicrometer Tracing is a Spring-agnostic tracing library that provides instrumentation and tracing integrations for applications.
- OpenTelemetryOpenTelemetry is an open-source observability framework for generating, collecting, and exporting telemetry such as traces, metrics, and logs.
- OTLP exporterAn OTLP exporter is a component that sends telemetry data using the OpenTelemetry Protocol.
- spanA span is a timed record of one operation or component segment within a distributed trace.
- placeholderA placeholder is a marked position in a prompt template that can be replaced with a value when the prompt is created.
- tool usageA tool call is a model-generated request for an application to invoke an external callable capability.
- agent workflowAn agentic workflow pattern is a design for organizing an AI agent's actions into a coordinated problem-solving process.
- MCP inspectorMCP Inspector is a debugging tool for connecting to Model Context Protocol servers, viewing their capabilities, and invoking their tools.
- prompt leakingPrompt leaking is a technique that elicits the contents of a language model's hidden or controlling prompt messages.
- defaultToolCallbacks()defaultToolCallbacks() is a ChatClient builder method that registers a provider's tool callbacks as default callable tools.
- MCP Filesystem serverThe Filesystem MCP Server is an MCP server that exposes filesystem operations to connected AI applications.
- GrafanaGrafana is an open-source platform for querying, visualizing, and alerting on data from monitoring and observability systems.
- TextReaderTextReader is a Spring AI document reader that loads text-file contents into document objects.
- assistantAn assistant message is a message containing a response generated by a language model.
- tool roleA tool message is a message containing instructions for invoking external tools to perform an action or fetch additional context.
- Spring InitializrSpring Initializr is a service that generates customizable Spring Boot project structures and build configurations.
- stuffing the promptPrompt stuffing is the technique of placing an entire source document or large body of reference text directly into a model prompt.
- goalA goal is a desired state or result that an agent seeks to achieve through its actions.
- planningAgent planning is the capability of selecting a path through available actions to achieve a desired goal.
- SearchRequestSearchRequest is a Spring AI request object that specifies the query and filtering or ranking parameters for vector-store similarity retrieval.
- Spring Cloud FunctionSpring Cloud Function is a Spring project for defining and composing functions that can be deployed and invoked through various bindings.
- Spring Data JDBCSpring Data JDBC is a Spring Data module that provides repository-based relational database access using JDBC.
- output conversionOutput conversion is the transformation of generated textual content into a structured Java object according to specified formatting instructions.
- defaultTools()defaultTools() is a ChatClient builder method that registers tools available to prompts sent through the resulting client.
- summarizationSummarization is the technique of condensing lengthy text into a shorter representation that preserves its essential meaning.
- sentiment analysisSentiment analysis is the computational classification of text according to expressed opinions or emotional polarity.
- Java recordA Java record is a restricted Java class for declaring compact immutable data-carrier types.
- OllamaOllama is a tool for running and serving open-source language models locally on user hardware.
- OpenAiAudioTranscriptionModelOpenAiAudioTranscriptionModel is a Spring AI component that converts spoken audio into text using OpenAI services.
- TranscriptionModelTranscriptionModel is a Spring AI interface for converting audio resources into text.
- image inputImage input is the inclusion of visual data in a model request so the model can interpret and answer questions about it.
- PromptRunnerPromptRunner is an Embabel API for sending prompts to a large language model and binding responses to objects.
- generative modelingGenerative AI is artificial intelligence that produces new content such as text, images, audio, or code from learned patterns.
- spring.ai.advisor metricThe spring.ai.advisor metric records counts and durations of operations performed through Spring AI advisors.
- spring.ai.chat.client metricThe spring.ai.chat.client metric records counts and durations of operations performed through ChatClient.
- vector store operation metricThe vector store operation metric records counts and durations of operations performed against vector stores.
- VectorStoreChatMemoryAdvisorVectorStoreChatMemoryAdvisor is a Spring AI advisor that stores chat messages as embeddings in a vector store and retrieves relevant messages as conversational context.
- SpeechModelSpeechModel is a Spring AI model interface that converts text into synthesized speech audio.
- parallelismParallelization is a technique that executes multiple processing paths concurrently and aggregates their results.
- QuestionAnswerAdvisorQuestionAnswerAdvisor is a Spring AI advisor that searches a vector store for documents related to a question and adds them as context to a prompt.
- FluxFlux is a Project Reactor reactive type that emits zero or more data elements asynchronously as they become available.
- newline-delimited JSONNewline-delimited JSON is a format in which each line contains a separate JSON value, allowing a sequence of values to be transmitted incrementally.
- stream()stream() is a ChatClient operation that initiates a streamed response instead of waiting for a complete response.
- text/event-streamtext/event-stream is a MIME type for transmitting a stream of server-sent event data, with each event commonly represented using data-prefixed fields.
- Prometheus endpointA Prometheus endpoint is an HTTP endpoint that exposes application metrics in a format that Prometheus can scrape.
- sentiment scoreA sentiment score is a numerical measure representing the polarity and degree of sentiment expressed by text.
- RelevancyEvaluatorRelevancyEvaluator is a Spring AI evaluator that uses a language model to judge whether an answer addresses a submitted question.
- Postgres driverThe PostgreSQL JDBC driver is a Java library that enables JDBC applications to connect to PostgreSQL databases.
- entity()entity() is a Spring AI ChatClient method that requests a language-model response converted to a specified Java type.
- ParameterizedTypeReferenceParameterizedTypeReference is a Spring type token that preserves generic type information when passing a parameterized Java type at runtime.
- OpenAiAudioSpeechOptionsOpenAiAudioSpeechOptions is a configuration object for selecting OpenAI text-to-speech voice, model, and audio format.
- SpeechPromptSpeechPrompt is a Spring AI request object containing text to synthesize and optional speech-generation settings.
- SpeechResponseSpeechResponse is a Spring AI response object containing synthesized audio bytes and related response information.
- context windowA context window is the maximum amount of tokenized input and output that a language model can handle in one interaction.
- embedAn embedding API is an API that converts text or other inputs into numerical vector representations.
- OpenAI-compatible APIAn OpenAI-compatible API is an API that follows enough of the OpenAI API's interface conventions to support clients designed for OpenAI.
- Azure OpenAIAzure OpenAI is Microsoft's Azure-hosted service for accessing OpenAI models through Azure infrastructure and authentication.
- AccessDeniedExceptionAccessDeniedException is an exception indicating that a security check rejected access to a protected operation.
- @EnableMethodSecurity@EnableMethodSecurity is a Spring Security annotation that enables authorization checks on secured method invocations.
- hasRole()hasRole() is a Spring Security expression function that tests whether the current security context contains a specified role.
- method-level securityMethod-level security is authorization enforced when application methods are invoked based on the caller's identity or authorities.
- @PreAuthorize@PreAuthorize is a Spring Security annotation that permits a method invocation only when its authorization expression evaluates to true.
- Spring Expression LanguageSpring Expression Language is an expression language for querying and manipulating object graphs and evaluating conditions within Spring applications.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
