Class BedrockTokenUsage

java.lang.Object
dev.langchain4j.model.output.TokenUsage
dev.langchain4j.model.bedrock.BedrockTokenUsage

public class BedrockTokenUsage extends TokenUsage
Bedrock-specific token usage that includes cache-related metrics.

This class extends TokenUsage to include AWS Bedrock prompt caching metrics: cacheWriteInputTokens() and cacheReadInputTokens().

Since:
1.0.0-beta2
  • Constructor Details

  • Method Details

    • cacheWriteInputTokens

      public Integer cacheWriteInputTokens()
      Returns The total cached token write count, or null if unknown.
      Returns:
      The total cached token write 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 BedrockTokenUsage 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.
    • equals

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

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

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

      public static BedrockTokenUsage.Builder builder()