Breakdown of the prompt token usage OpenAI can return for a request, distinguishing tokens served from the prompt cache, tokens written to it, and tokens spent on audio input from the total prompt tokens. Matches the shape of the prompt_tokens_details field of a chat completion and the input_tokens_details field of a response, which differ in which of these fields they populate.


Properties

PropertyReturnsDescription
audioTokensIntegerNumber of prompt tokens that came from audio input.
cachedTokensIntegerNumber of prompt tokens that were served from OpenAI's prompt cache rather than freshly processed.
cacheWriteTokensIntegerNumber of prompt tokens written to the prompt cache for a later request to reuse. From GPT-5.6 on these are charged above the ordinary input rate, so they are counted separately when costing a call.

Methods

getCachedTokens()

Returns: Integer

Number of prompt tokens that were served from OpenAI's prompt cache rather than freshly processed.

getCacheWriteTokens()

Returns: Integer

Number of prompt tokens written to the prompt cache for a later request to reuse. From GPT-5.6 on these are charged above the ordinary input rate, so they are counted separately when costing a call.

getAudioTokens()

Returns: Integer

Number of prompt tokens that came from audio input.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.