Spring AI 1.0 Launch: Production‑Ready Java AI Framework Unveiled
Spring AI 1.0, the first production‑grade Java AI framework, introduces ready‑to‑use APIs, seamless model integration, enterprise‑level RAG engine, smart tool calling, and three development modes, empowering developers to rapidly build, customize, and fully control AI applications with major model providers like OpenAI, Anthropic, DeepSeek.
Core Breakthroughs Overview
Production‑Ready API : stable, reliable, complete production‑grade interfaces after multiple milestone releases.
Integrated Model Access : seamless integration of major models such as OpenAI, Anthropic, Vertex AI, DeepSeek.
Enterprise‑Level RAG Engine : advanced retrieval‑augmented generation framework to unlock enterprise knowledge‑base value.
Smart Tool Invocation : simplifies AI agent development, allowing models to operate enterprise systems effortlessly.
API Architecture Upgrade (0.8→1.0)
1. Model and Client Decoupling
<code>// New client construction under the upgraded architecture
ChatClient chatClient = new ChatClient(
new OpenAiChatModel("your-api-key"), // model implementation decoupled from client
new PromptTemplate("您好,请回答:{{question}}")
);
</code>Core Change : model logic is completely separated from client logic; the
ChatModelinterface focuses on model communication while
ChatClientorchestrates the overall flow, enabling flexible composition of different model implementations with a unified client API.
2. Session Memory Standardization
<code>@Bean
public ChatMemoryRepository chatMemoryRepository() {
return new JdbcChatMemoryRepository(jdbcTemplate);
}
chatClient.exchange(
new ChatMemoryId("user-123"),
new UserMessage("新的问题")
);
</code>Core Upgrade : the new
ChatMemoryRepositorystandardizes session memory, offering three major benefits:
Multiple Storage Options : supports in‑memory, JDBC, Redis, Cassandra and other persistence solutions.
Intelligent Context Management : automatically optimizes window size to ensure coherent conversations.
Unified Access Pattern : simplifies development and improves code consistency.
3. RAG Engine Upgrade – Document Processing Pipeline
<code>ChatClient chatClient = ChatClient.builder()
.chatModel(chatModel)
.advisor(new VectorStoreAdvisor(
vectorStore,
embeddingClient,
List.of(
new DocumentMetadataFilterPostProcessor(filterCriteria),
new DocumentRerankingPostProcessor(threshold)
)
))
.build();
</code>Core Improvement : the new DocumentPostProcessors API replaces fragmented interfaces, delivering enterprise‑grade RAG capabilities:
Precise Retrieval Quality : fine‑grained filtering, ranking, and re‑ranking dramatically improve relevance.
Composable Processing Pipelines : flexible customization of document pre‑ and post‑processing workflows.
Context Optimization : intelligent selection and prioritization maximize the value of the model's input window.
4. Agent Framework Upgrade – From Function Calls to Tool Calls
Spring AI 1.0 upgrades the function‑call API to a standards‑compliant tool‑call API, making intelligent‑agent development intuitive and efficient.
<code>// Old function call
FunctionCallback.builder()
.function("getCurrentWeather", new WeatherService())
.description("获取指定位置的天气情况")
.inputType(WeatherRequest.class)
.build();
// New tool call
FunctionToolCallback.builder("getCurrentWeather", new WeatherService())
.description("获取指定位置的天气情况")
.inputType(WeatherRequest.class)
.build();
</code>Core Change :
FunctionCallback→
ToolCallback ChatClient.Builder.defaultFunctions()→
ChatClient.Builder.defaultTools() FunctionCallingOptions→
ToolCallingChatOptionsMajor Breakthrough : annotation‑based tool definitions multiply developer productivity.
<code>class SmartHomeTools {
@Tool(description = "控制房间灯光开关")
public void turnLight(String roomName, boolean on) {
log.info("将{}房间的灯光设置为:{}", roomName, on ? "开启" : "关闭");
}
}
String response = chatClient.prompt()
.user("请把客厅的灯打开")
.tools(new SmartHomeTools()) // auto‑detects @Tool methods
.call()
.content();
</code>This upgrade boosts agent‑application development efficiency by several folds, turning complex configurations into simple annotations.
DeepSeek Native Integration
Spring AI 1.0 fully integrates the DeepSeek model with a dedicated API, preserving the model's chain‑of‑thought in responses, enabling:
Complete Reasoning Capture : captures every step of the model's thinking without loss during protocol conversion.
Enhanced Explainability : displays the full logical chain, increasing user trust.
Fine‑Grained Access Control : separate access to reasoning process and final answer for diverse scenarios.
<code>public void deepSeekReasonerExample() {
DeepSeekChatOptions options = DeepSeekChatOptions.builder()
.model(DeepSeekApi.ChatModel.DEEPSEEK_REASONER.getValue())
.temperature(0.1f) // low temperature for consistent reasoning
.build();
Prompt prompt = new Prompt("两个数字:9.11 和 9.8,哪个更大?请详细解释", options);
ChatResponse response = chatModel.call(prompt);
DeepSeekAssistantMessage assistantMsg = (DeepSeekAssistantMessage) response.getResult().getOutput();
String reasoning = assistantMsg.getReasoningContent();
String answer = assistantMsg.getText();
System.out.println("推理过程:" + reasoning);
System.out.println("最终答案:" + answer);
}
</code>Quick integration requires a single Maven dependency:
<code><dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-deepseek</artifactId>
<version>1.0.0</version>
</dependency>
</code>Spring AI Development Modes – Three Flexible Choices
Spring AI 1.0 offers three abstraction layers to suit projects of any complexity. The diagram below illustrates the three‑layer architecture.
1. Auto‑Configuration Mode – Rapid Start
Applicable Scenarios : quick prototyping, standard AI applications.
Just add the starter dependency and minimal configuration:
<code><dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-deepseek</artifactId>
<version>1.0.0</version>
</dependency>
</code> <code># application.properties
spring.ai.deepseek.api-key=${DEEPSEEK_API_KEY}
spring.ai.deepseek.model=deepseek-chat
spring.ai.deepseek.temperature=0.7
</code> <code>@RestController
public class AiController {
@Autowired
private ChatClient chatClient; // auto‑injected configured client
@GetMapping("/chat")
public String chat(@RequestParam String message) {
return chatClient.prompt().user(message).call().content();
}
}
</code>2. Manual Configuration Mode – Flexible Customization
Applicable Scenarios : enterprise applications, custom parameter tuning, hybrid model usage.
Java configuration gives precise control over model behavior:
<code>@Configuration
public class DeepSeekConfig {
@Bean
public ChatModel deepSeekChatModel(@Value("${deepseek.api-key}") String apiKey) {
DeepSeekChatOptions options = DeepSeekChatOptions.builder()
.model(DeepSeekApi.ChatModel.DEEPSEEK_CHAT.getValue())
.temperature(0.5f)
.topP(0.95f)
.build();
return new DeepSeekChatModel(apiKey, options);
}
@Bean
public ChatClient deepSeekChatClient(ChatModel deepSeekModel) {
return ChatClient.builder()
.chatModel(deepSeekModel)
.defaultSystemPrompt("你是一个专业助手")
.build();
}
}
</code>3. Low‑Level API Mode – Full Control
Applicable Scenarios : advanced customization, special integration needs, performance optimization.
Directly operate the low‑level API for maximum flexibility:
<code>@Service
public class AdvancedDeepSeekService {
private final DeepSeekApi deepSeekApi;
public AdvancedDeepSeekService(@Value("${deepseek.api-key}") String apiKey) {
this.deepSeekApi = new DeepSeekApi(apiKey);
}
// Streaming response handling
public Flux<String> streamChat(String prompt) {
DeepSeekChatRequest request = DeepSeekChatRequest.builder()
.model(DeepSeekApi.ChatModel.DEEPSEEK_CHAT.getValue())
.messages(List.of(new UserMessage(prompt)))
.stream(true)
.temperature(0.3f)
.build();
return deepSeekApi.streamingChat(request)
.filter(chunk -> chunk.getChoices().get(0).getDelta().getContent() != null)
.map(chunk -> chunk.getChoices().get(0).getDelta().getContent());
}
}
</code>The three‑layer API architecture lets you choose the abstraction level that best fits your project, from zero‑config quick start to full‑control custom implementations.
Spring AI Chinese Documentation
Spring AI Chinese tutorial is now officially released at https://javaai.pig4cloud.com , covering Java AI development, SDKs such as spring‑ai, langchain4j, deepseek4j, and more.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
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.