> Markdown version of [/videos/1141-building-ai-driven-spring-applications-with-spring-ai?t=501](https://www.wearedevelopers.com/videos/1141-building-ai-driven-spring-applications-with-spring-ai?t=501). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Building AI-Driven Spring Applications With Spring AI Tired of AI vendor lock-in? Spring AI treats LLMs like swappable dependencies. Discover how to easily build RAG pipelines and map JSON strings to strongly-typed Java objects. - **Speakers:** [Sandra Ahlgrimm](https://www.wearedevelopers.com/@sandra-ahlgrimm), [Timo Salm](https://www.wearedevelopers.com/@timo-salm) - **Event:** World Congress 2024 - **Published:** August 20, 2024 - **Duration:** 32:14 - **URL:** https://www.wearedevelopers.com/videos/1141-building-ai-driven-spring-applications-with-spring-ai ## Summary The evolution of artificial intelligence—from early machine learning models requiring task-specific training data to highly capable generative foundation models—has fundamentally shifted software development. Rather than maintaining separate algorithms for distinct tasks like entity recognition or sentiment analysis, developers can now leverage versatile large language models to power a wide array of features. This transition dramatically reduces development bottlenecks and associated costs, but integrating these advanced models into enterprise architectures often introduces new challenges regarding maintainability and vendor lock-in. Spring AI addresses these engineering hurdles by extending the widely adopted Spring framework's core design principles to artificial intelligence integrations. By emphasizing high abstraction, Spring AI empowers Java developers to seamlessly connect to various AI providers, allowing teams to natively switch from a locally hosted Ollama model to cloud-based Azure OpenAI instances via simple dependency and configuration updates rather than complex application code rewrites. Developers also benefit from out-of-the-box instructions that automatically map a model's underlying JSON output directly into strongly-typed Java objects, eliminating brittle parsing logic and increasing overall productivity. Moving beyond basic text generation, the ecosystem simplifies the deployment of advanced foundation model adaptations. Engineering teams can quickly implement real-time function calling to bridge static models with live application states, enabling the AI to dynamically query external APIs before generating a response. Additionally, Spring AI streamlines retrieval-augmented generation (RAG) by offering built-in ETL document pipelines. These pipelines effortlessly extract, transform, embed, and load proprietary business data into vector databases like Redis, allowing applications to execute semantic similarity searches that securely inject necessary context into prompts without exceeding token limits. **Keywords:** java spring ai integration, generative ai foundation models, llm vendor abstraction, ollama local model deployment, azure openai configuration, strongly-typed json mapping, real-time function calling, retrieval-augmented generation, rag pipeline implementation, vector database similarity search, redis vector store, document etl processing, dynamic prompt engineering, multi-modal ai applications, enterprise ai deployment ## Chapters 1. **Session overview and setup for building AI applications** (00:00) — Introduction to the speakers and the agenda for building applications with Spring AI. 1. **Evolution from artificial intelligence to generative AI models** (01:05) — How the history of artificial intelligence progressed from early machine learning to modern deep learning and generative models. 1. **Comparing traditional machine learning with flexible foundation models** (02:54) — Why foundation models offer flexible, reusable alternatives to traditional machine learning bottlenecks. 1. **Understanding prompt tokenization in large language models** (04:38) — How large language models map subsets of characters into tokens to predict the most likely next word. 1. **Exploring common use cases for modern generative AI** (05:25) — Examples of applying AI to generate text, code, images, and domain-specific structured data. 1. **Why developers choose the Spring framework for enterprise APIs** (07:03) — How the Spring ecosystem prioritizes developer productivity and production readiness for the Java virtual machine. 1. **Core design principles and capabilities of Spring AI** (08:21) — How Spring AI abstracts model integrations and structured outputs while supporting advanced patterns like retrieval and multimodality. 1. **Demonstrating a local recipe finder powered by Ollama** (09:54) — A local demonstration using llama 3 and ollama to generate context-specific recipe results. 1. **Implementing a basic AI chat client in Spring** (11:50) — Configuring an AI chat client with prompt templates and mapping outputs directly to strongly typed JSON objects. 1. **Switching model vendors to Azure OpenAI using configurations** (16:19) — How abstractions in Spring AI allow swapping from a local model to Azure OpenAI without altering core business logic. 1. **Adapting foundation models with targeted context techniques** (20:05) — Why techniques like prompt engineering, function calling, and retrieval-augmented generation outperform basic foundational knowledge for business data. 1. **Implementing AI function calling for dynamic data lookup** (24:27) — Creating a function interface in Spring that allows the language model to query external APIs and mock services. 1. **Understanding vector databases and retrieval-augmented generation pipelines** (27:20) — How ETL pipelines process, split, and embed documents into a vector database for similarity searches. 1. **Integrating vector stores and RAG capabilities in Spring AI** (28:57) — Wiring up Redis vector stores and question-answer advisors to inject proprietary PDF data into the generation context. ## Related Moments - [Overview of enterprise Java and generative AI](https://www.wearedevelopers.com/videos/1554-java-meets-ai-empowering-spring-developers-to-build-intelligent-apps) (from "Java Meets AI: Empowering Spring Developers to Build Intelligent Apps") - [Building intelligent interactions with the Spring AI framework](https://www.wearedevelopers.com/videos/1554-java-meets-ai-empowering-spring-developers-to-build-intelligent-apps) (from "Java Meets AI: Empowering Spring Developers to Build Intelligent Apps") - [Overview of generative AI and the presentation agenda](https://www.wearedevelopers.com/videos/1001-langchain4j-an-introduction-for-impatient-developers) (from "Langchain4J - An Introduction for Impatient Developers") - [Embedding generative AI in enterprise software platforms](https://www.wearedevelopers.com/videos/916-beyond-the-hype-real-world-ai-strategies-panel) (from "Beyond the Hype: Real-World AI Strategies Panel") - [Exploring AI integrations in modern agile development workflows](https://www.wearedevelopers.com/videos/631-chatgpt-create-a-presentation) (from "ChatGPT: Create a Presentation!") - [Scaling generative AI use cases across large enterprises](https://www.wearedevelopers.com/videos/916-beyond-the-hype-real-world-ai-strategies-panel) (from "Beyond the Hype: Real-World AI Strategies Panel") ## Related Articles - [Stephan Gillich - Bringing AI Everywhere](https://www.wearedevelopers.com/magazine/489-stephan-gillich-bringing-ai-everywhere) - [MLOps And AI Driven Development](https://www.wearedevelopers.com/magazine/82-mlops-and-ai-driven-development) - [Exploring AI: Opportunities and Risks for Developers](https://www.wearedevelopers.com/magazine/522-exploring-ai-opportunities-and-risks-for-developers) - [Navigating the AI Shift](https://www.wearedevelopers.com/magazine/629-navigating-the-ai-shift) ## Related Jobs - [AI Software Engineer (Germany)](https://www.wearedevelopers.com/jobs/48317-ai-software-engineer-germany) at **Sunhat** - [AI & Machine Learning Engineer (all genders)](https://www.wearedevelopers.com/jobs/48217-ai-machine-learning-engineer-all-genders) at **msg** - [AI Full Stack Engineer](https://www.wearedevelopers.com/jobs/ext/1354435-ai-full-stack-engineer) at **Almedia** - [Principal Software Engineer, Enterprise AI Platform](https://www.wearedevelopers.com/jobs/ext/1467292-principal-software-engineer-enterprise-ai-platform) at **GitHub** - [Head of AI Applications](https://www.wearedevelopers.com/jobs/ext/1456210-head-of-ai-applications) at **ZEISS Group** - [Principal Field Architect - AI Agents](https://www.wearedevelopers.com/jobs/ext/1442858-principal-field-architect-ai-agents) at **Twilio**