Class DeepSeekCompletionResponse

java.lang.Object
de.entwicklertraining.api.base.ApiResponse<DeepSeekCompletionRequest>
de.entwicklertraining.deepseek4j.DeepSeekResponse<DeepSeekCompletionRequest>
de.entwicklertraining.deepseek4j.chat.completion.DeepSeekCompletionResponse

public final class DeepSeekCompletionResponse extends DeepSeekResponse<DeepSeekCompletionRequest>
Represents a response from the DeepSeek Chat Completion API. Provides methods to access various parts of the response data.
  • Constructor Details

    • DeepSeekCompletionResponse

      public DeepSeekCompletionResponse(org.json.JSONObject json, DeepSeekCompletionRequest request)
      Constructs a DeepSeekCompletionResponse.
      Parameters:
      json - The raw JSON response object.
      request - The original request that led to this response.
  • Method Details

    • getId

      public String getId()
      Gets the unique identifier for the chat completion.
      Returns:
      The ID string, or null if not present. [cite: 30]
    • getObject

      public String getObject()
      Gets the object type, which is always "chat.completion".
      Returns:
      The object type string, or null if not present.
    • getCreated

      public long getCreated()
      Gets the Unix timestamp (in seconds) of when the chat completion was created.
      Returns:
      The creation timestamp, or 0 if not present.
    • getModel

      public String getModel()
      Gets the model used for the chat completion.
      Returns:
      The model ID string, or null if not present.
    • getSystemFingerprint

      public String getSystemFingerprint()
      Gets the system fingerprint representing the backend configuration used for the request.
      Returns:
      The system fingerprint string, or null if not present.
    • getChoices

      Gets the list of chat completion choices.
      Returns:
      A list of Choice objects, or an empty list if not present or invalid. [cite: 31, 32]
    • getUsage

      Gets the usage statistics for the completion request.
      Returns:
      A Usage object, or null if the "usage" field is not present or invalid. [cite: 27]
    • assistantMessage

      public String assistantMessage()
      Convenience method to get the message content from the first choice.
      Returns:
      The content string, or null if no choices or message content exists.
    • finishReason

      public String finishReason()
      Convenience method to get the finish reason from the first choice.
      Returns:
      The finish reason string (e.g., "stop", "tool_calls"), or null if no choices exist.