Artificial Intelligence 5 min read

Introducing DeepSeek4j 1.4: A Java Spring Boot Integration for DeepSeek AI with Chain‑of‑Thought and Streaming Support

The article introduces DeepSeek4j 1.4, a Java Spring Boot library that overcomes existing framework limitations by preserving DeepSeek's chain‑of‑thought capabilities, adding full reactive streaming, and providing a simple one‑line API along with quick‑start instructions and code examples.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Introducing DeepSeek4j 1.4: A Java Spring Boot Integration for DeepSeek AI with Chain‑of‑Thought and Streaming Support

DeepSeek R1 is popular for its chain‑of‑thought capabilities, but mainstream frameworks such as Spring AI lack proper support for preserving chain content and streaming output.

The newly released DeepSeek4j 1.4 addresses these limitations by providing a dedicated Java integration library.

Project address: https://github.com/pig-mesh/deepseek4j

Documentation: https://javaai.pig4cloud.com/deepseek

Why DeepSeek4j?

DeepSeek4j is a Java‑centric framework that enables one‑line integration of DeepSeek models.

Limitations of existing frameworks

Chain‑of‑thought content loss: the core reasoning process is ignored.

Incompatible response mode: cannot handle “think first, conclude later” output.

Parameter restrictions: temperature, top_p settings are ineffective.

Incomplete streaming support leads to poor user experience.

Solution

Based on the OpenAI4J architecture, the author created DeepSeek4j, which enhances DeepSeek‑specific features and adds full reactive support.

Core Features

Complete preservation of chain‑of‑thought and billing.

Reactive streaming processing.

Simple and elegant API design.

Spring Boot starter with auto‑configuration for Spring Boot 2.x/3.x.

Built‑in debugging page.

Detailed request/response logging.

Flexible proxy configuration.

Support for reactive programming.

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 (application.yml):

deepseek:
  api-key: your-api-key-here
  base-url: https://api.deepseek.com/v1 # optional, defaults to official API

Basic 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);
}

For front‑end debugging, open the provided sse.html file and point it to the backend SSE endpoint to view the inference process in real time.

JavaStreamingSpring BootReactiveDeepSeekChain-of-ThoughtAI integration
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.