Uses of Class
dev.langchain4j.model.output.TokenUsage
Packages that use TokenUsage
Package
Description
AWS Bedrock integration for LangChain4j.
Model mocks for tests: they need no network, answer the way a test tells them to, and record the requests they
receive.
-
Uses of TokenUsage in dev.langchain4j.agentic.observability
Methods in dev.langchain4j.agentic.observability that return TokenUsageModifier and TypeMethodDescription@Nullable TokenUsagePlannerModelResponse.tokenUsage()Returns the token usage of this model call, ornullif the provider didn't report it.Methods in dev.langchain4j.agentic.observability that return types with arguments of type TokenUsageModifier and TypeMethodDescriptionAgentInvocation.tokenUsage()Returns the token usage of an AI agent, which is the total of all its LLM calls when it calls tools, or of the decision call of a decision agent.Constructors in dev.langchain4j.agentic.observability with parameters of type TokenUsageModifierConstructorDescriptionPlannerModelResponse(AgenticScope agenticScope, AgentInstance agent, @Nullable TokenUsage tokenUsage, @Nullable String modelName) -
Uses of TokenUsage in dev.langchain4j.model.anthropic
Subclasses of TokenUsage in dev.langchain4j.model.anthropicMethods in dev.langchain4j.model.anthropic with parameters of type TokenUsage -
Uses of TokenUsage in dev.langchain4j.model.anthropic.internal.mapper
Methods in dev.langchain4j.model.anthropic.internal.mapper that return TokenUsageModifier and TypeMethodDescriptionstatic TokenUsageAnthropicMapper.toTokenUsage(AnthropicUsage anthropicUsage) -
Uses of TokenUsage in dev.langchain4j.model.bedrock
Subclasses of TokenUsage in dev.langchain4j.model.bedrockModifier and TypeClassDescriptionclassBedrock-specific token usage that includes cache-related metrics.Methods in dev.langchain4j.model.bedrock with parameters of type TokenUsage -
Uses of TokenUsage in dev.langchain4j.model.chat.response
Methods in dev.langchain4j.model.chat.response that return TokenUsageMethods in dev.langchain4j.model.chat.response with parameters of type TokenUsageModifier and TypeMethodDescriptionChatResponse.Builder.tokenUsage(TokenUsage tokenUsage) ChatResponseMetadata.Builder.tokenUsage(TokenUsage tokenUsage) -
Uses of TokenUsage in dev.langchain4j.model.decision.response
Methods in dev.langchain4j.model.decision.response that return TokenUsageModifier and TypeMethodDescriptionDecisionResponse.tokenUsage()The token usage of the call, ornullif the model did not report it.DecisionResponseMetadata.tokenUsage()Methods in dev.langchain4j.model.decision.response with parameters of type TokenUsageModifier and TypeMethodDescriptionDecisionResponse.Builder.tokenUsage(TokenUsage tokenUsage) DecisionResponseMetadata.Builder.tokenUsage(TokenUsage tokenUsage) -
Uses of TokenUsage in dev.langchain4j.model.embedding.response
Methods in dev.langchain4j.model.embedding.response that return TokenUsageModifier and TypeMethodDescriptionEmbeddingResponse.tokenUsage()EmbeddingResponseMetadata.tokenUsage()Methods in dev.langchain4j.model.embedding.response with parameters of type TokenUsageModifier and TypeMethodDescriptionEmbeddingResponse.Builder.tokenUsage(TokenUsage tokenUsage) EmbeddingResponseMetadata.Builder.tokenUsage(TokenUsage tokenUsage) -
Uses of TokenUsage in dev.langchain4j.model.google.genai
Subclasses of TokenUsage in dev.langchain4j.model.google.genaiModifier and TypeClassDescriptionclassGoogle GenAI-specificTokenUsagethat additionally exposes the token counts reported by Gemini for cached content, for thinking and for tool results fed back to the model.Methods in dev.langchain4j.model.google.genai with parameters of type TokenUsageModifier and TypeMethodDescriptionGoogleGenAiTokenUsage.add(TokenUsage that) Adds the token usage of two responses together. -
Uses of TokenUsage in dev.langchain4j.model.googleai
Subclasses of TokenUsage in dev.langchain4j.model.googleaiMethods in dev.langchain4j.model.googleai with parameters of type TokenUsage -
Uses of TokenUsage in dev.langchain4j.model.mistralai.internal.mapper
Methods in dev.langchain4j.model.mistralai.internal.mapper that return TokenUsageModifier and TypeMethodDescriptionstatic TokenUsageMistralAiMapper.tokenUsageFrom(MistralAiUsage mistralAiUsage) -
Uses of TokenUsage in dev.langchain4j.model.openai
Subclasses of TokenUsage in dev.langchain4j.model.openaiModifier and TypeClassDescriptionclassToken usage of an OpenAI image generation or edit request, as returned byOpenAiImageModelinResponse.tokenUsage().classMethods in dev.langchain4j.model.openai with parameters of type TokenUsageModifier and TypeMethodDescriptionOpenAiImageTokenUsage.add(TokenUsage that) OpenAiTokenUsage.add(TokenUsage that) -
Uses of TokenUsage in dev.langchain4j.model.openaiofficial
Subclasses of TokenUsage in dev.langchain4j.model.openaiofficialMethods in dev.langchain4j.model.openaiofficial with parameters of type TokenUsage -
Uses of TokenUsage in dev.langchain4j.model.output
Methods in dev.langchain4j.model.output that return TokenUsageModifier and TypeMethodDescriptionTokenUsage.add(TokenUsage that) Adds the token usage of two responses together.static TokenUsageTokenUsage.sum(TokenUsage first, TokenUsage second) Adds two token usages.@Nullable TokenUsageResponse.tokenUsage()Get the token usage statistics.Methods in dev.langchain4j.model.output with parameters of type TokenUsageModifier and TypeMethodDescriptionTokenUsage.add(TokenUsage that) Adds the token usage of two responses together.static <T> Response<T> Response.from(T content, @Nullable TokenUsage tokenUsage) Create a new Response.static <T> Response<T> Response.from(T content, @Nullable TokenUsage tokenUsage, @Nullable FinishReason finishReason) Create a new Response.static <T> Response<T> Response.from(T content, @Nullable TokenUsage tokenUsage, @Nullable FinishReason finishReason, @Nullable Map<String, Object> metadata) Create a new Response.static TokenUsageTokenUsage.sum(TokenUsage first, TokenUsage second) Adds two token usages.Constructors in dev.langchain4j.model.output with parameters of type TokenUsageModifierConstructorDescriptionResponse(T content, @Nullable TokenUsage tokenUsage, @Nullable FinishReason finishReason) Create a new Response.Response(T content, @Nullable TokenUsage tokenUsage, @Nullable FinishReason finishReason, @Nullable Map<String, Object> metadata) Create a new Response. -
Uses of TokenUsage in dev.langchain4j.model.scoring.response
Methods in dev.langchain4j.model.scoring.response that return TokenUsageModifier and TypeMethodDescriptionScoringResponse.tokenUsage()ScoringResponseMetadata.tokenUsage()Methods in dev.langchain4j.model.scoring.response with parameters of type TokenUsageModifier and TypeMethodDescriptionScoringResponse.Builder.tokenUsage(TokenUsage tokenUsage) ScoringResponseMetadata.Builder.tokenUsage(TokenUsage tokenUsage) -
Uses of TokenUsage in dev.langchain4j.service
Methods in dev.langchain4j.service that return TokenUsageModifier and TypeMethodDescriptionResult.tokenUsage()Returns aggregate token usage over all calls to theChatModel.Methods in dev.langchain4j.service with parameters of type TokenUsageConstructors in dev.langchain4j.service with parameters of type TokenUsageModifierConstructorDescriptionResult(T content, TokenUsage tokenUsage, List<Content> sources, FinishReason finishReason, List<ToolExecution> toolExecutions) -
Uses of TokenUsage in dev.langchain4j.service.decision
Methods in dev.langchain4j.service.decision that return TokenUsage -
Uses of TokenUsage in dev.langchain4j.service.tool
Methods in dev.langchain4j.service.tool that return TokenUsageMethods in dev.langchain4j.service.tool with parameters of type TokenUsageModifier and TypeMethodDescriptionToolServiceResult.Builder.aggregateTokenUsage(TokenUsage aggregateTokenUsage) -
Uses of TokenUsage in dev.langchain4j.store.embedding
Methods in dev.langchain4j.store.embedding that return TokenUsageConstructors in dev.langchain4j.store.embedding with parameters of type TokenUsage -
Uses of TokenUsage in dev.langchain4j.test.judge
Methods in dev.langchain4j.test.judge that return TokenUsageModifier and TypeMethodDescriptionJudgeResponse.tokenUsage()The tokens the judge model used for this evaluation, added up over all requests the judge sent.Methods in dev.langchain4j.test.judge with parameters of type TokenUsageModifier and TypeMethodDescriptionJudgeResponse.Builder.tokenUsage(TokenUsage tokenUsage) Sets the tokens used by the judge model. -
Uses of TokenUsage in dev.langchain4j.test.mock
Methods in dev.langchain4j.test.mock with parameters of type TokenUsageModifier and TypeMethodDescriptionMockChatModel.withTokenUsage(@Nullable TokenUsage tokenUsage) Reports the given token usage in the response to every request, except for a step that gives the whole response: that one reports exactly its own token usage.MockStreamingChatModel.withTokenUsage(@Nullable TokenUsage tokenUsage) Reports the given token usage in the response to every request, except for a step that gives the whole response: that one reports exactly its own token usage. -
Uses of TokenUsage in dev.langchain4j.test.service
Methods in dev.langchain4j.test.service that return TokenUsageModifier and TypeMethodDescriptionAiServiceInvocation.tokenUsage()Returns the tokens used, summed over the calls that the AI Service itself made to its chat model during the invocation (for example, before and after executing tools).