Class AnthropicTokenUsage

java.lang.Object
dev.langchain4j.model.output.TokenUsage
dev.langchain4j.model.anthropic.AnthropicTokenUsage

public class AnthropicTokenUsage extends TokenUsage
  • Constructor Details

    • AnthropicTokenUsage

      public AnthropicTokenUsage(AnthropicTokenUsage.Builder builder)
    • AnthropicTokenUsage

      @Deprecated(forRemoval=true, since="1.0.0-beta4") public AnthropicTokenUsage(Integer inputTokenCount, Integer outputTokenCount, Integer cacheCreationInputTokens, Integer cacheReadInputTokens)
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use builder() instead
      Creates a new AnthropicTokenUsage instance with the given input, output token counts and cache creation/read input tokens.
      Parameters:
      inputTokenCount - The input token count, or null if unknown.
      outputTokenCount - The output token count, or null if unknown.
      cacheCreationInputTokens - The total cached token created count, or null if unknown.
      cacheReadInputTokens - The total cached token read count, or null if unknown.
  • Method Details

    • cacheCreationInputTokens

      public Integer cacheCreationInputTokens()
      Returns The total cached token created count, or null if unknown.
      Returns:
      The total cached token created count, or null if unknown.
    • cacheReadInputTokens

      public Integer cacheReadInputTokens()
      Returns The total cached token read count, or null if unknown.
      Returns:
      The total cached token read count, or null if unknown.
    • add

      public AnthropicTokenUsage add(TokenUsage that)
      Description copied from class: TokenUsage
      Adds the token usage of two responses together.

      Fields which are null in both responses will be null in the result.

      Overrides:
      add in class TokenUsage
      Parameters:
      that - The token usage to add to this one.
      Returns:
      a new TokenUsage instance with the token usage of both responses added together.
    • toString

      public String toString()
      Overrides:
      toString in class TokenUsage
    • builder

      public static AnthropicTokenUsage.Builder builder()