java.lang.Object
com.sap.ai.sdk.foundationmodels.openai.generated.model.CompletionUsage

public class CompletionUsage extends Object
Usage statistics for the completion request.
  • Constructor Details

    • CompletionUsage

      public CompletionUsage()
  • Method Details

    • promptTokens

      @Nonnull public CompletionUsage promptTokens(@Nonnull Integer promptTokens)
      Set the promptTokens of this CompletionUsage instance and return the same instance.
      Parameters:
      promptTokens - Number of tokens in the prompt.
      Returns:
      The same instance of this CompletionUsage class
    • getPromptTokens

      @Nonnull public Integer getPromptTokens()
      Number of tokens in the prompt.
      Returns:
      promptTokens The promptTokens of this CompletionUsage instance.
    • setPromptTokens

      public void setPromptTokens(@Nonnull Integer promptTokens)
      Set the promptTokens of this CompletionUsage instance.
      Parameters:
      promptTokens - Number of tokens in the prompt.
    • completionTokens

      @Nonnull public CompletionUsage completionTokens(@Nonnull Integer completionTokens)
      Set the completionTokens of this CompletionUsage instance and return the same instance.
      Parameters:
      completionTokens - Number of tokens in the generated completion.
      Returns:
      The same instance of this CompletionUsage class
    • getCompletionTokens

      @Nonnull public Integer getCompletionTokens()
      Number of tokens in the generated completion.
      Returns:
      completionTokens The completionTokens of this CompletionUsage instance.
    • setCompletionTokens

      public void setCompletionTokens(@Nonnull Integer completionTokens)
      Set the completionTokens of this CompletionUsage instance.
      Parameters:
      completionTokens - Number of tokens in the generated completion.
    • totalTokens

      @Nonnull public CompletionUsage totalTokens(@Nonnull Integer totalTokens)
      Set the totalTokens of this CompletionUsage instance and return the same instance.
      Parameters:
      totalTokens - Total number of tokens used in the request (prompt + completion).
      Returns:
      The same instance of this CompletionUsage class
    • getTotalTokens

      @Nonnull public Integer getTotalTokens()
      Total number of tokens used in the request (prompt + completion).
      Returns:
      totalTokens The totalTokens of this CompletionUsage instance.
    • setTotalTokens

      public void setTotalTokens(@Nonnull Integer totalTokens)
      Set the totalTokens of this CompletionUsage instance.
      Parameters:
      totalTokens - Total number of tokens used in the request (prompt + completion).
    • completionTokensDetails

      @Nonnull public CompletionUsage completionTokensDetails(@Nullable CompletionUsageCompletionTokensDetails completionTokensDetails)
      Set the completionTokensDetails of this CompletionUsage instance and return the same instance.
      Parameters:
      completionTokensDetails - The completionTokensDetails of this CompletionUsage
      Returns:
      The same instance of this CompletionUsage class
    • getCompletionTokensDetails

      @Nonnull public CompletionUsageCompletionTokensDetails getCompletionTokensDetails()
      Get completionTokensDetails
      Returns:
      completionTokensDetails The completionTokensDetails of this CompletionUsage instance.
    • setCompletionTokensDetails

      public void setCompletionTokensDetails(@Nullable CompletionUsageCompletionTokensDetails completionTokensDetails)
      Set the completionTokensDetails of this CompletionUsage instance.
      Parameters:
      completionTokensDetails - The completionTokensDetails of this CompletionUsage
    • getCustomFieldNames

      @Nonnull public Set<String> getCustomFieldNames()
      Get the names of the unrecognizable properties of the CompletionUsage.
      Returns:
      The set of properties names
    • getCustomField

      @Nullable @Deprecated public Object getCustomField(@Nonnull String name) throws NoSuchElementException
      Deprecated.
      Use toMap() instead.
      Get the value of an unrecognizable property of this CompletionUsage instance.
      Parameters:
      name - The name of the property
      Returns:
      The value of the property
      Throws:
      NoSuchElementException - If no property with the given name could be found.
    • toMap

      @Nonnull public Map<String,Object> toMap()
      Get the value of all properties of this CompletionUsage instance including unrecognized properties.
      Returns:
      The map of all properties
    • setCustomField

      public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue)
      Set an unrecognizable property of this CompletionUsage instance. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
      Parameters:
      customFieldName - The name of the property
      customFieldValue - The value of the property
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object