Class DeepSeekApi
java.lang.Object
org.springframework.ai.deepseek.api.DeepSeekApi
Single class implementation of the DeepSeek Chat Completion API:
https://platform.deepseek.com/api-docs/api/create-chat-completion
- Author:
- Geng Rong
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static final record
Represents a chat completion response returned by model, based on the provided input.static final record
Represents a streamed chunk of a chat completion response returned by model, based on the provided input.static enum
The reason the model stopped generating tokens.static final record
Message comprising the conversation.static final record
Creates a model response for the given chat conversation.static enum
DeepSeek Chat Completion Modelsstatic class
Represents a tool the model may call.static final record
Log probability information for the choice.static final record
Usage statistics for the completion request. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeepSeekApi
(String baseUrl, ApiKey apiKey, org.springframework.util.MultiValueMap<String, String> headers, String completionsPath, String betaPrefixPath, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api. -
Method Summary
Modifier and TypeMethodDescriptionstatic DeepSeekApi.Builder
builder()
org.springframework.http.ResponseEntity<DeepSeekApi.ChatCompletion>
chatCompletionEntity
(DeepSeekApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.reactor.core.publisher.Flux<DeepSeekApi.ChatCompletionChunk>
chatCompletionStream
(DeepSeekApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.reactor.core.publisher.Flux<DeepSeekApi.ChatCompletionChunk>
chatCompletionStream
(DeepSeekApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.
-
Field Details
-
DEFAULT_CHAT_MODEL
-
-
Constructor Details
-
DeepSeekApi
public DeepSeekApi(String baseUrl, ApiKey apiKey, org.springframework.util.MultiValueMap<String, String> headers, String completionsPath, String betaPrefixPath, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new chat completion api.- Parameters:
baseUrl
- api base URL.apiKey
- DeepSeek apiKey.headers
- the http headers to use.completionsPath
- the path to the chat completions endpoint.betaPrefixPath
- the prefix path to the beta feature endpoint.restClientBuilder
- RestClient builder.webClientBuilder
- WebClient builder.responseErrorHandler
- Response error handler.
-
-
Method Details
-
chatCompletionEntity
public org.springframework.http.ResponseEntity<DeepSeekApi.ChatCompletion> chatCompletionEntity(DeepSeekApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request.- Returns:
- Entity response with
DeepSeekApi.ChatCompletion
as a body and HTTP status code and headers.
-
chatCompletionStream
public reactor.core.publisher.Flux<DeepSeekApi.ChatCompletionChunk> chatCompletionStream(DeepSeekApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request. Must have the stream property set to true.- Returns:
- Returns a
Flux
stream from chat completion chunks.
-
chatCompletionStream
public reactor.core.publisher.Flux<DeepSeekApi.ChatCompletionChunk> chatCompletionStream(DeepSeekApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request. Must have the stream property set to true.additionalHttpHeader
- Optional, additional HTTP headers to be added to the request.- Returns:
- Returns a
Flux
stream from chat completion chunks.
-
builder
-