About Spring AI Demos
Spring AI Demos is an MCP server published by GabsDev in the RAG category: spring AI demos: OpenAI & Ollama chat, RAG with pgvector, image generation, text-to-speech, MCP server/client (Java 25, Spring Boot 4, Spring AI 2).
The repository has 9 stars and 4 forks, with the last commit a month ago. Recent commit activity is the strongest signal that reported issues will get attention.
Install
git clone https://github.com/GabsDev/spring-ai-demosThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Spring AI Demos
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 14 hours ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- !License declaredNo license file. Legally you have no right to use it in a product.
- ✓Tests presentA test suite exists in the repository.
- !Dependencies pinnedNo lockfile. Installs can pull different code over time.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
1 check has not been run yet.
README
Spring AI Demos
A collection of hands-on demo applications built with Spring AI, Spring Boot 4 and Java 25, showing how to integrate LLMs (OpenAI and Ollama), build a RAG pipeline, generate images and audio, and wire models to external tools through MCP (Model Context Protocol).
Each app is an independent Spring Boot project with its own Maven wrapper, so you can run any of them on its own.
Stack
| Technology | Version |
|---|---|
| Java | 25 |
| Spring Boot | 4.1.x |
| Spring AI | 2.0.x |
| Models | OpenAI (gpt-4o-mini), Ollama (qwen3:4b) |
| Embeddings | Ollama nomic-embed-text |
| Vector Store | PostgreSQL + pgvector |
| MCP | Streamable HTTP (@McpTool) |
Apps
1. springai-openai — OpenAI Chat Playground
Free chat, expert personas, code generation/explanation, and structured (typed) outputs with Spring AI's ChatClient.
Key endpoints (AiController):
GET /greeting— one-line helloPOST /chat,POST /chat-expert— free chat, Java/Spring expert personaPOST /generate-code,POST /explain-code— code generation and explanationPOST /chat-format,POST /analyze— structured summaries and analysisGET /city-info?city=,POST /classify-typed— typed records (CityInfo,TicketClassification)POST /generate-code-json,POST /explain-code-json,POST /expert-architect-json— typed JSON outputsGET /chat-metadata?prompt=— answer plus rawChatResponsemetadata
Requires: OPENAI_API_KEY (see spring.config.import=optional:file:.env[.properties]).
2. springai-ollama — Ollama Chat Playground (local, no cloud)
The same feature set as the OpenAI app, backed by a local Ollama server with qwen3:4b. No API keys, fully offline.
Requires: Ollama running at http://localhost:11434 with qwen3:4b pulled.
3. springai-rag — RAG with PostgreSQL + pgvector
Upload a PDF, index it into pgvector using Ollama embeddings, then ask questions grounded in your own documents.
Endpoints:
POST /index-upload/pdf— multipart PDF upload →PagePdfDocumentReader→TokenTextSplitter(chunk 800, min 350 chars) → pgvectorPOST /rag/ask— top-4similaritySearch+ grounded prompt (answers only from context)
Requires: PostgreSQL with pgvector (spring_ai_rag database, schema auto-created), Ollama with qwen3:4b and nomic-embed-text.
4. springai-image-generate — Text-to-Image
Generate a PNG from a text prompt via the OpenAI Images API.
GET /api/images/generate?prompt=— returns inline PNG bytes (b64_json)
Requires: OPENAI_API_KEY.
5. springai-audio — Text-to-Speech
Convert text to MP3 using the OpenAI TTS API.
GET /api/tts?text=— returnsaudio/mpegbytes (gpt-4o-mini-tts, voicealloy)
Requires: OPENAI_API_KEY.
6. springai-mcp-server — MCP Server (weather tools)
A Spring AI MCP server exposing weather tools over streamable HTTP on port 8081 (endpoint /mcp).
Tools (@McpTool):
getCurrentWeatherTemperature(city)— temperature for Santiago, Madrid, Buenos Aires, Ciudad de México (demo data)getWeatherRecommendation(city)— clothing advice per city
7. springai-mcp-client — MCP Client (LLM + tools)
An Ollama-backed chat client that consumes the MCP server's weather tools via tool-calling.
GET /api/weather/ask?question=— natural-language weather question (e.g., "¿qué temperatura hace en Santiago?")
Requires: MCP server (app 6) running on http://localhost:8081/mcp, Ollama with qwen3:4b.
How to run
Each app is self-contained. From the app folder:
# OpenAI / Image / Audio apps: create a .env with your key first
echo "OPENAI_API_KEY=sk-..." > .env
# Ollama / RAG apps: make sure Ollama is running
ollama pull qwen3:4b
ollama pull nomic-embed-text # only for RAG
# RAG: PostgreSQL with pgvector (e.g. via docker)
docker run -d --name pgvector -p 5432:5432 \
-e POSTGRES_DB=spring_ai_rag -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres \
pgvector/pgvector:pg17
# MCP client needs the MCP server on :8081 first, then:
./mvnw spring-boot:run
Notes
springai-ollamaintentionally mirrors the OpenAI app's controller/service structure — only the model provider changes, which makes it easy to compare cloud vs. local inference.- Tests are
@SpringBootTestcontext-load smoke tests (7 total). .envfiles with real API keys are gitignored — provide your own.
License
Demo material for learning purposes.
README fetched from the repository 14 hours ago. The original is authoritative.