Introducing Spring AI: Building a Simple Chat Application with DeepSeek
This article introduces Spring AI, explains its core features for integrating various AI models, and walks through creating a Spring Boot chat application that connects to the DeepSeek model using both synchronous and streaming endpoints.
Spring AI is a Java framework within Spring that simplifies AI integration by providing unified interfaces and portable APIs for various AI models.
Key features include support for major AI model providers (Anthropic, OpenAI, Microsoft, Amazon, Google, Ollama), multiple model types (chat, embedding, text‑to‑image, audio transcription, text‑to‑speech), cross‑provider API, vector‑database integration, observability, retrieval‑augmented generation (RAG), and Spring Boot starters.
In the engineering example, a Spring Boot project is created (via start.spring.io) with Maven, adding the spring-ai-openai-spring-boot-starter dependency (version 1.0.0‑M6) and configuring DeepSeek API credentials in application properties.
Configuration snippet:
spring.ai.openai.api-key=<insert deepseek api key here>
spring.ai.openai.base-url=https://api.deepseek.com
spring.ai.openai.chat.options.model=deepseek-chatA REST controller injects OpenAiChatModel and defines two endpoints: /ai/call for synchronous chat using chatModel.call(message) , and /ai/stream for reactive streaming using chatModel.stream(prompt) .
Supporting classes such as Prompt , ChatResponse , and related metadata are shown, illustrating how messages, options, and model responses are modeled.
The article concludes that the simple DeepSeek chat application demonstrates Spring AI’s capability to accelerate AI engineering and that future releases will expand functionality.
iKang Technology Team
The iKang tech team shares their technical and practical experiences in medical‑health projects.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.