Class DeepSeekApi

java.lang.Object
org.springframework.ai.deepseek.api.DeepSeekApi

public class DeepSeekApi extends Object
Single class implementation of the DeepSeek Chat Completion API: https://platform.deepseek.com/api-docs/api/create-chat-completion
Author:
Geng Rong
  • Field Details

  • 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

      public static DeepSeekApi.Builder builder()