LLM and AI-Infused Applications with Java & Spring AI

February 7, 2026 ยท View on GitHub

Samples showing how to build Java applications powered by Generative AI and Large Language Models (LLMs) using Spring AI.

๐Ÿ› ๏ธ Pre-Requisites

  • Java 25
  • Podman/Docker

๐Ÿ’ก Use Cases

๐Ÿง  Models

Chat Models

Chat completion with LLMs via different model providers:

Embedding Models

Vector transformation (embeddings) with LLMs via different model providers:

Image Models

Image generation with LLMs via different model providers:

Audio Models

Speech generation with LLMs via different model providers:

Speech transcription with LLMs via different model providers:

Moderation Models

Coming soon

๐Ÿ“ Patterns

Prompts, Messages, and Templates

Prompting using simple text:

Prompting using structured messages and roles:

Prompting using templates:

Structured Output

Converting LLM output to structured JSON and Java objects:

Multimodality

Including various media in prompts with LLMs:

Tool Calling

Tool calling with LLMs via different model providers:

Memory

Using chat memory to preserve context in conversations with LLMs:

Guardrails

Guardrails for input and output with LLMs via different model providers:

๐Ÿ“ฅ Data Ingestion

Document Readers

Reading and vectorizing documents with LLMs via Ollama:

Document Transformers

Document transformation with LLMs via Ollama:

  • Metadata
    Enrich documents with keywords and summary metadata for enhanced retrieval.
  • Splitters
    Divide documents into chunks to fit the LLM context window.

๐Ÿ”ข Vector Stores

Coming soon

๐Ÿ”„ Retrieval Augmented Generation (RAG)

Question answering with documents using different RAG flows (with Ollama and PGVector):

Sequential RAG

Branching RAG

Conditional RAG

๐Ÿ“Š Observability

LLM Observability

LLM Observability for different model providers:

Vector Store Observability

Vector Store Observability for different vector stores:

โš™๏ธ Model Context Protocol

Integrations with MCP Servers for providing contexts to LLMs.

๐Ÿ“‹ Evaluation

Coming soon

๐Ÿค– Agents

Coming soon

๐Ÿ“š References and Additional Resources

Conferences

Videos

Demos

Workshops