Class OpenAiImageTokenUsage
OpenAiImageModel
in Response.tokenUsage().
In addition to the input, output and total token counts, it reports how many of the input and output tokens were image tokens and how many were text tokens. OpenAI prices these differently, so the split is needed to compute the cost of a request.
Only models that report usage (such as gpt-image-1) return it. For other models (such as
dall-e-3), Response#tokenUsage() is null.
- Since:
- 1.21.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classHow many tokens were image tokens and how many were text tokens. -
Method Summary
Modifier and TypeMethodDescriptionadd(TokenUsage that) Adds the token usage of two responses together.builder()booleaninthashCode()Returns the breakdown of the input tokens into image and text tokens, ornullif OpenAI did not report it.Returns the breakdown of the output tokens into image and text tokens, ornullif OpenAI did not report it.toString()Methods inherited from class TokenUsage
inputTokenCount, outputTokenCount, sum, sum, totalTokenCount
-
Method Details
-
inputTokensDetails
Returns the breakdown of the input tokens into image and text tokens, ornullif OpenAI did not report it. -
outputTokensDetails
Returns the breakdown of the output tokens into image and text tokens, ornullif OpenAI did not report it. -
add
Description copied from class:TokenUsageAdds the token usage of two responses together.Fields which are null in both responses will be null in the result.
When one of the two is an instance of a
TokenUsagesubclass, that subclass performs the addition, so that the extra fields it carries are preserved. The result then has the type of that subclass, no matter which of the two sides it was on.A subclass carrying extra fields should therefore override this method and sum those fields as well. When neither side overrides it, there is nothing that knows how to sum the extra fields and the result is a plain
TokenUsage.- Overrides:
addin classTokenUsage- Parameters:
that- The token usage to add to this one.- Returns:
- a new
TokenUsageinstance with the token usage of both responses added together.
-
equals
- Overrides:
equalsin classTokenUsage
-
hashCode
public int hashCode()- Overrides:
hashCodein classTokenUsage
-
toString
- Overrides:
toStringin classTokenUsage
-
builder
-