Skip to content

fix: add text_tokens and image_tokens to PromptTokensDetails#1782

Open
fuleinist wants to merge 1 commit intoopenai:masterfrom
fuleinist:fix/add-text-image-tokens-to-prompt-details
Open

fix: add text_tokens and image_tokens to PromptTokensDetails#1782
fuleinist wants to merge 1 commit intoopenai:masterfrom
fuleinist:fix/add-text-image-tokens-to-prompt-details

Conversation

@fuleinist
Copy link

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Add text_tokens and image_tokens fields to the PromptTokensDetails interface in src/resources/completions.ts.

These fields are returned by the OpenAI API in the prompt_tokens_details object when using audio models like gpt-4o-audio-preview and gpt-4o-mini-audio-preview, but are currently not typed in the SDK.

Example API response:

"prompt_tokens_details": {
  "cached_tokens": 0,
  "audio_tokens": 21,
  "text_tokens": 11,
  "image_tokens": 0
}

Additional context & links

Fixes #1718

The OpenAI API returns text_tokens and image_tokens in the prompt_tokens_details
field when using audio models like gpt-4o-audio-preview. These fields were missing
from the TypeScript type definitions.

Fixes openai#1718
@fuleinist fuleinist requested a review from a team as a code owner March 21, 2026 08:32
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.

text_tokens and image_tokens not documented or typed

1 participant