Spaces:
Paused

icebear icebear0828 Claude Opus 4.6 commited on
Commit
fadda70
·
unverified ·
1 Parent(s): b87bedf

fix: pass through cached_tokens from Codex API (#58)

Browse files

* fix: pass through cached_tokens and reasoning_tokens from Codex API (#55)

The proxy was only extracting input_tokens/output_tokens from Codex
response usage, dropping input_tokens_details.cached_tokens and
output_tokens_details.reasoning_tokens. This caused cached token
counts to always show as 0 for downstream clients.

Fixed across all three output formats (OpenAI, Anthropic, Gemini)
in both streaming and non-streaming modes.

Closes #55

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: pass reasoning_tokens through onUsage in Anthropic/Gemini translators

The Anthropic and Gemini streaming translators were not forwarding
reasoning_tokens via onUsage, unlike the OpenAI translator. Also
fixes Gemini non-streaming path leaking cached_tokens: undefined
by using conditional spread consistent with other translators.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

9 files changed +77 -6
Files changed (9)
src/routes/shared/proxy-handler.ts+3-3
src/translation/codex-event-extractor.ts+2
src/translation/codex-to-anthropic.ts+13-2
src/translation/codex-to-gemini.ts+10-1
src/translation/codex-to-openai.ts+27
src/types/anthropic.ts+2
src/types/codex-events.ts+12
src/types/gemini.ts+1
src/types/openai.ts+7