Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/openai-base/src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function buildChatCompletionsUsage(

const promptDetails = usage.prompt_tokens_details
const promptTokensDetails = {
...(promptDetails?.cached_tokens
...(promptDetails?.cached_tokens != null
? { cachedTokens: promptDetails.cached_tokens }
: {}),
...(promptDetails?.audio_tokens
Expand Down Expand Up @@ -98,7 +98,7 @@ export function buildResponsesUsage(
// Despite the SDK types marking these required, they can be undefined at runtime.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const cachedTokens = usage.input_tokens_details?.cached_tokens
if (cachedTokens && cachedTokens > 0) {
if (cachedTokens != null) {
result.promptTokensDetails = {
...result.promptTokensDetails,
cachedTokens,
Expand Down