Class TokenUsage

java.lang.Object
com.sap.ai.sdk.orchestration.model.TokenUsage

public class TokenUsage extends Object
Usage of tokens in the response
  • Constructor Details

    • TokenUsage

      protected TokenUsage()
      Default constructor for TokenUsage.
  • Method Details

    • completionTokens

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

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

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

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

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

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

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

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

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

      @Nonnull public TokenUsage promptTokensDetails(@Nullable TokenUsagePromptTokensDetails promptTokensDetails)
      Set the promptTokensDetails of this TokenUsage instance and return the same instance.
      Parameters:
      promptTokensDetails - The promptTokensDetails of this TokenUsage
      Returns:
      The same instance of this TokenUsage class
    • getPromptTokensDetails

      @Nonnull public TokenUsagePromptTokensDetails getPromptTokensDetails()
      Get promptTokensDetails
      Returns:
      promptTokensDetails The promptTokensDetails of this TokenUsage instance.
    • setPromptTokensDetails

      public void setPromptTokensDetails(@Nullable TokenUsagePromptTokensDetails promptTokensDetails)
      Set the promptTokensDetails of this TokenUsage instance.
      Parameters:
      promptTokensDetails - The promptTokensDetails of this TokenUsage
    • completionTokensDetails

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

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

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

      @Nonnull public Set<String> getCustomFieldNames()
      Get the names of the unrecognizable properties of the TokenUsage.
      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 TokenUsage 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 TokenUsage 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 TokenUsage 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
    • create

      public static TokenUsage.Builder create()
      Create a type-safe, fluent-api builder object to construct a new TokenUsage instance with all required arguments.