Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DRAFT: Dev/add usage details to Usage class #726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 20, 2025
Merged

Conversation

WJPBProjects
Copy link
Contributor

@WJPBProjects WJPBProjects commented May 20, 2025

PR to enhance the Usage object and related logic, to support more granular token accounting, matching the details available in the OpenAI Responses API . Specifically, it:

  • Adds input_tokens_details and output_tokens_details fields to the Usage dataclass, storing detailed token breakdowns (e.g., cached_tokens, reasoning_tokens).
  • Flows this change through
  • Updates and extends tests to match
  • Adds a test for the Usage.add method

Motivation

  • Aligns the SDK’s usage with the latest OpenAI responses API Usage object
  • Supports downstream use cases that require fine-grained token usage data (e.g., billing, analytics, optimization) requested by startups

@WJPBProjects WJPBProjects marked this pull request as ready for review May 20, 2025 14:18
Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally looks good, one quick change request

Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine actually

@WJPBProjects WJPBProjects merged commit 466b44d into main May 20, 2025
5 checks passed
@WJPBProjects WJPBProjects deleted the dev/add-usage-details branch May 20, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants