Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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#6662
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

@red-sprout

@red-sprout red-sprout commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Preserve token usage returned by the OpenAI Images API in
    OpenAiImageResponseMetadata.
  • Add the Spring AI-owned OpenAiImageUsage value type without exposing OpenAI
    SDK types in the public API.
  • Cover complete usage data, absent usage, absent output token details, legacy
    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 unchanged
and delegates to the new constructor. When usage is absent, the existing
equals(), hashCode(), and toString() behavior is preserved. Responses
containing usage now include that usage in their value semantics.

Required token counts use long, while optional output text and image token
counts use nullable Long values.

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
red-sprout force-pushed the feature/openai-image-usage-metadata branch from afdbe5f to 29e8ed2 Compare July 22, 2026 15:09
@red-sprout
red-sprout marked this pull request as ready for review July 22, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose OpenAI image token usage through OpenAiImageResponseMetadata

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.