Boost Java AI Apps with DeepSeek4j: Full Chain Support & Reactive Streaming
DeepSeek4j 1.4 brings a Java‑native integration framework that fully preserves DeepSeek's chain‑of‑thought capabilities, adds reactive streaming, and offers a one‑line Spring Boot starter, enabling developers to quickly embed the model with simple configuration and rich debugging tools.
Why DeepSeek4j?
DeepSeek R1 is praised for its powerful chain‑of‑thought abilities, yet mainstream frameworks like Spring AI lack proper support for chain content retention and streaming output. The newly released DeepSeek4j 1.4 addresses these limitations.
Project repository: https://github.com/pig-mesh/deepseek4j
Documentation: https://javaai.pig4cloud.com/deepseek
Existing Framework Limitations
Chain content loss: The core reasoning process of R1 is completely ignored.
Incompatible response mode: Cannot handle "think first, conclude later" output patterns.
Parameter restrictions: Critical parameters such as temperature and top_p become ineffective.
Streaming handling is incomplete: Leads to poor user experience.
Solution
The author of the Pig project built DeepSeek4j on top of the excellent OpenAI4J architecture, creating a ready‑to‑use solution specifically for DeepSeek.
Core Features
✨ Complete preservation of chain‑of‑thought and billing.
🚀 Reactive streaming support.
🛠 Simple and elegant API design.
📦 Out‑of‑the‑box Spring Boot integration for versions 2.x and 3.x.
💡 Built‑in debugging page.
🔍 Detailed request/response logging.
🔧 Flexible proxy configuration.
⚡️ Full reactive programming support.
Quick Start
Add Dependency :
<dependency>
<groupId>io.github.pig-mesh.ai</groupId>
<artifactId>deepseek-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>Configuration Parameters (in application.yml):
deepseek:
api-key: your-api-key-here
base-url: https://api.deepseek.com/v1 # optional, defaults to official API addressBasic Usage :
@Autowired
private DeepSeekClient deepSeekClient;
// SSE streaming response
@GetMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ChatCompletionResponse> chat(String prompt) {
return deepSeekClient.chatFluxCompletion(prompt);
}Frontend Debugging
Open the sse.html file in the project root, enter the backend SSE endpoint, and click Send to view the inference process and final result in real time. The page includes the complete front‑end implementation code for reference.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
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.
