Artificial Intelligence 5 min read

DeepSeek4j 1.4: A Java Integration Framework for DeepSeek AI Models

DeepSeek4j 1.4 introduces a Java‑native framework that fully preserves DeepSeek's chain‑of‑thought and billing features, adds reactive streaming support, and provides a Spring Boot starter for effortless integration, accompanied by quick‑start code, configuration examples, and a built‑in debugging UI.

Architecture Digest
Architecture Digest
Architecture Digest
DeepSeek4j 1.4: A Java Integration Framework for DeepSeek AI Models

DeepSeek R1 is popular for its chain‑of‑thought capabilities, but mainstream frameworks such as Spring AI lack proper support for chain content retention and streaming output. The newly released DeepSeek4j 1.4 version addresses these limitations with important updates.

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

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

Why DeepSeek4j is needed?

DeepSeek4j is a DeepSeek model integration framework built specifically for the Java ecosystem. Its API design is concise and elegant, allowing integration with a single line of code.

Limitations of existing frameworks

Chain‑of‑thought content loss: The core reasoning process of R1 is completely ignored.

Incompatible response mode: Unable to handle "think first, conclude later" output patterns.

Parameter restrictions: Key parameters like temperature and top_p become ineffective.

Streaming handling incomplete: Poor user experience.

Solution

The author of the open‑source project Pig, based on the excellent architecture of OpenAI4J, created an out‑of‑the‑box solution for DeepSeek—DeepSeek4j.

Enhanced support for DeepSeek’s unique chain‑of‑thought and billing features.

Comprehensive reactive support via Project Reactor.

Provides a Spring Boot Starter for automatic configuration.

Core Features

Full preservation of chain‑of‑thought capability and billing.

Reactive streaming processing.

Simple and elegant API design.

Ready‑to‑use Spring Boot integration supporting 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 parameters: Add the following to application.yml

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

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

Front‑end debugging: Double‑click the sse.html file in the project root to open the debugging page, enter the backend SSE endpoint, and view the inference process and final result in real time. The page includes the full front‑end implementation code for reference.

Additional promotional content offers free access to a book management system by scanning a QR code, and lists previous articles on related topics.

JavaintegrationAISpring BootAPIReactiveDeepSeek
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

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.