Expose OpenAI Image Usage Metadata#6662
Open
red-sprout wants to merge 1 commit into
spring-projects:mainspring-projects/spring-ai:mainfrom
red-sprout:feature/openai-image-usage-metadatared-sprout/spring-ai:feature/openai-image-usage-metadataCopy head branch name to clipboard
Open
Expose OpenAI Image Usage Metadata#6662red-sprout wants to merge 1 commit intospring-projects:mainspring-projects/spring-ai:mainfrom red-sprout:feature/openai-image-usage-metadatared-sprout/spring-ai:feature/openai-image-usage-metadataCopy head branch name to clipboard
red-sprout wants to merge 1 commit into
spring-projects:mainspring-projects/spring-ai:mainfrom
red-sprout:feature/openai-image-usage-metadatared-sprout/spring-ai:feature/openai-image-usage-metadataCopy head branch name to clipboard
Conversation
Map token usage from OpenAI image responses into a Spring AI-owned metadata type while preserving legacy construction and behavior when usage is absent. Closes spring-projects#6661 Signed-off-by: red-sprout <jjw05015@gmail.com>
red-sprout
force-pushed
the
feature/openai-image-usage-metadata
branch
from
July 22, 2026 15:09
afdbe5f to
29e8ed2
Compare
red-sprout
marked this pull request as ready for review
July 22, 2026 15:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenAiImageResponseMetadata.OpenAiImageUsagevalue type without exposing OpenAISDK types in the public API.
metadata behavior, and value semantics with unit tests.
Closes #6661
Scope
This change only maps usage from image generation responses. It does not change
image editing, retries, batching, observability, or common image usage
abstractions.
Compatibility
The existing
OpenAiImageResponseMetadata(Long)constructor remains unchangedand delegates to the new constructor. When usage is absent, the existing
equals(),hashCode(), andtoString()behavior is preserved. Responsescontaining usage now include that usage in their value semantics.
Required token counts use
long, while optional output text and image tokencounts use nullable
Longvalues.