
In this lecture, I will give an introduction to the course.
In this lecture, I will cover the prerequisites that are needed for this course.
In this lecture, all the slides that are used in this course are available.
In this lecture, the source code thats done in this course are available.
Explore the pre-LLM era, How we interact with computers for solutions ? How its changed since the release of ChatGPT.
Trace the evolution of Large Language Models, from early iterations to the cutting-edge architectures shaping today's AI landscape.
Examine the benefits, hurdles, and diverse applications of LLMs, showcasing their impact across various industries and use cases.
Learn how to sign up for ChatGPT, navigate its features, and begin experimenting with this powerful AI tool in practical scenarios.
Learn the basics of Spring AI and its integration with OpenAI to build intelligent applications seamlessly.
Set up your OpenAI account and explore the Playground to experiment with generative AI capabilities.
Install and configure Java efficiently using SDKMan to prepare your development environment.
Create and configure your Java project with Gradle and IntelliJ for streamlined development.
Build a chat-based AI application using Spring's ChatClient to interact with OpenAI's platform.
Use Insomnia to test and debug your AI chat endpoints effectively.
Dive into the inner workings of ChatClient's auto-configuration to understand its architecture and functionality.
Understand the key concepts of prompts, tokens, and tokenization and how they impact AI responses.
Explore the temperature parameter to control the creativity of OpenAI's generated responses.
Learn how to manage response length effectively using the max_tokens parameter.
Learn the roles of system, assistant, and user messages in structuring AI interactions effectively.
See practical examples of system, assistant, and user messages in action to design structured conversations
Implement real-time streaming to display OpenAI responses incrementally as they are generated.
Learn how to install, configure, and authorize GitHub Copilot in IntelliJ IDEs
Use @ControllerAdvice and @ExceptionHandler to create centralized error handling in your Spring Boot application
Learn how to construct effective prompts using the Prompt and ChatClient to streamline AI interactions
Learn to design and implement a robust endpoint that leverages string templates to dynamically generate and customize code for various use cases.
Learn how to effectively utilize PromptTemplate to structure and streamline the exchange of messages in AI applications
Learn how to use StringTemplate to dynamically inject values into prompts, making them more flexible, reusable, and context-aware.
Understand the fundamentals of Spring AI Advisors and how they can be used to modify AI interactions.
Explore the SimpleLoggerAdvisor to log requests and responses, aiding in debugging and monitoring AI interactions.
Learn how to create a custom advisor to tailor AI interactions to specific application needs.
This lecture teaches how to create clear, structured prompts that lead to accurate and meaningful AI outputs.
Dive into a practical example by creating a travel plan prompt, showcasing prompt engineering techniques in a real-world scenario.
Explore the concept of prompt injection, its potential risks and the techniques to mitigate prompt injection..
This lecture explains zero-shot and few-shot prompting techniques to improve AI performance with minimal examples.
This lecture explains zero-shot and few-shot prompting techniques to improve AI performance with minimal examples.
Learners will explore how Chain of Thought Prompting helps guide AI through logical, step-by-step problem-solving.
Learn how to craft and utilize multi-step prompts to guide LLMs through complex tasks, achieving more detailed and accurate responses.
Understand how LLMs generate structured data and why it's crucial for AI-driven applications.
Explore how the entity() function and BeanOutputConverter work together to produce structured outputs seamlessly in Spring AI.
Learn how few-shot examples enhance prompt engineering to produce more accurate structured outputs.
Explore how the entity() function and BeanOutputConverter work together to produce structured outputs seamlessly in Spring AI.
Get an inside look at how Spring AI handles structured outputs behind the scenes, from prompt to parsed response.
Learn how to use ParameterizedTypeReference to handle structured outputs involving collection types like lists and maps effectively.
Learn how to generate and parse structured outputs of type Map using Spring AI, ideal for handling key-value data responses.
Understand the fundamentals of function calling and why it's essential for AI integration. Discover how OpenAI uses function calling to access and manipulate external data.
Learn how to use OpenAI's function calling to fetch system details like name and time. This lecture demonstrates how AI can interact with your device for dynamic information retrieval.
Go behind the scenes to understand how tool calling operates internally—covering request preparation, function resolution, and response parsing in Spring AI.
See tool calling in action as you integrate with OpenExchangeRates to fetch real-time currency exchange rates using Spring AI.
Learn how to fetch real-time weather data using function-based tool calling with OpenAI, demonstrating practical integration for dynamic responses
Explore how Spring Beans can be used with tool calling to retrieve live weather data in a modular and scalable way.
Discover how to generate structured outputs using tool calling, enabling reliable parsing of data from external APIs.
Learn how to customize tool calling behavior using ToolContext and the returnDirect flag to control response handling and execution flow.
Course Description
Unlock the power of Generative AI in your Java applications with Spring AI, OpenAI, Ollama and the Model Context Protocol (MCP)!
In this hands-on course, you'll learn how to build intelligent, scalable, production-ready AI applications using the Spring Boot ecosystem.
You'll start with your first prompt and go on to build full RAG systems, MCP servers and clients, observable AI services, and applications with short-term and long-term memory, gaining the practical skills to bring LLMs into real-world projects.
Here's a breakdown of what you'll learn in each section:
Course Introduction & Setup
Understand the course structure, prerequisites, and how to set up your Java and Spring AI environment.
Introduction to Large Language Models (LLMs), OpenAI & ChatGPT
Learn the basics of LLMs, their evolution, advantages and challenges, and how OpenAI's ChatGPT fits into modern AI workflows.
Getting Started with Spring AI and OpenAI API
Configure your project and IDE, build your first chat app using ChatClient, see how ChatClient auto-configuration works under the hood, and understand prompts, tokens, system/user/assistant messages, OpenAI request parameters, and streaming responses.
Global Error Handling with GitHub Copilot
Set up GitHub Copilot in IntelliJ and use it to build centralized error handling with ControllerAdvice.
Streamlining Message Passing with StringTemplates & PromptTemplates
Build prompts with Prompt and ChatClient, and use StringTemplate and PromptTemplate to create dynamic, reusable prompts for LLMs.
Sprng AI Advisors: Enhancing AI Interactions
Intercept, log and enhance AI interactions using Spring AI Advisors, including SimpleLoggerAdvisor and your own custom advisor.
Prompt Engineering with Spring AI
Master prompt engineering techniques such as zero-shot, few-shot, chain-of-thought and multi-step prompting, and learn how to recognize and mitigate prompt injection.
Generating Structured Data with Spring AI
Create structured outputs using prompt engineering and Spring AI's converters, including entity objects, lists and maps, and see how structured outputs work under the hood.
Tool Calling (Function Calling) with Spring AI
Connect your AI apps to external systems with tool calling to fetch live data such as system time, weather and currency rates. Learn how tool calling works under the hood, and use Spring Beans, returnDirect, ToolContext and ToolCallbacks.
RAG in Action: Empowering LLMs with External Knowledge
Understand Retrieval-Augmented Generation (RAG), grounding, prompt stuffing, and why stuffing the whole context doesn't scale.
Building RAG Applications (Retrieval-Augmented Generation)
Build an end-to-end RAG-powered Q&A system using PgVector, document indexing, semantic retrieval and generation, and see how embeddings are created under the hood.
Document Ingestion Strategies
Ingest and chunk PDFs, Word files and plain text using different document readers and splitters, including paragraph and token-based chunking.
Exploring Multimodality: Image Generation
Generate images from natural language prompts with OpenAI's image models, customize them with image options, and save Base64 outputs to the file system.
Exploring Multimodality: Vision Capabilities
Analyze images using LLMs, upload images as files or multipart requests, and build a real-world invoice processing use case.
Exploring Multimodality: Audio Capabilities
Convert text into realistic speech using TTS, and transcribe or translate speech to text using the Whisper API.
Set Up Claude Code as a Coding Assistant
Install and configure Claude Code and use it as an AI-powered coding assistant in your development workflow.
Spring AI Observability using OpenTelemetry
Add end-to-end observability to Spring AI applications with OpenTelemetry. Cover logs, metrics and traces, Logback integration, and Grafana dashboards, then build custom metrics using MeterRegistry, the Observation API and @Observed.
MCP: Model Context Protocol Fundamentals
Understand MCP's architecture, its key components, how AI benefits from MCP, and how the HTTP and STDIO transports work in Spring AI.
Build a Weather MCP Server using Spring WebMVC
Build a Weather MCP Server with MCP tools, test it with MCP Inspector, compare Plain HTTP with Streamable HTTP, write integration tests with WireMock, and understand sync vs async MCP servers.
Build a Currency Converter MCP Server using Spring WebFlux
Build a reactive MCP Server with the WebFlux starter, connect it to a live currency exchange API, and test it with MCP Inspector and WireMock.
MCP Client using Spring WebMVC
Build Spring AI MCP clients that connect to multiple MCP servers, invoke tools from natural-language prompts, log tool calls with ToolCallback, and manage stateful and stateless connections.
MCP Client using Spring WebFlux
Build a fully reactive MCP client that uses McpAsyncClient to connect an LLM to multiple MCP servers and exposes both regular and streaming chat endpoints.
REST API + MCP Server: They Can Coexist
Add an MCP server to an existing Inventory REST API without changing its behavior, reuse the existing service layer, and integrate it with a Spring MCP client.
Chat Memory using Spring AI
Learn why LLMs forget and how Spring AI manages conversational context with ChatMemory, ChatMemoryRepository and MessageChatMemoryAdvisor.
Use in-memory storage, PostgreSQL persistence with JdbcChatMemoryRepository, message eviction, and manual memory management with ChatModel.
Then build semantic chat memory on PgVector, inspecting similarity scores, adding similarity thresholds and de-duplication, and weighing the trade-offs.
Long-Term Memory: Episodic, Semantic and Procedural
Give your AI application memory that lasts beyond a single conversation.
Build episodic memory (dated conversation summaries recalled later), semantic memory (a user profile the model updates through a tool) and procedural memory (business procedures loaded on demand with a human in the loop), then see all of them at work in a chat UI.
Building Local AI Apps with Spring AI and Ollama
Run LLMs locally using Ollama, integrate them with Spring AI, and build applications that don't depend on external APIs.
Appendix: Foundations of Generative AI
Look deeper at how LLMs are trained and how GPT models evolved from GPT-1 to today.
By the end of this course, you'll be able to build full-stack AI-powered applications with Java and Spring Boot, using cloud models, local models, vision, audio, RAG, MCP, observability, and short-term and long-term memory.
You'll walk away with the confidence and experience to bring Generative AI into production-ready Java applications.