feat(OpenAI): Add Image Response usage #571
Merged
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.
What:
Description:
This PR adds support for tracking token usage in image generation, editing, and variation responses that got introduced in
gpt-image-1
(https://platform.openai.com/docs/api-reference/images/object).The changes include:
ImageResponseUsage
andImageResponseUsageInputTokensDetails
to handle usage dataCreateResponse
,EditResponse
, andVariationResponse
) to include usage informationThe usage information includes:
This feature allows developers to track and monitor token consumption when working with OpenAI's image generation endpoints.
Related:
This PR addresses the need to track token usage in image-related operations, similar to how it's already implemented for text-based operations. It helps developers better understand and optimize their usage of OpenAI's image generation capabilities.
fixes: #569 (issue)
closes: #570 (dupe)