Repository navigation
Fix thinking-token cost undercount; send Gemini images at low resolution - #4
Merged
Merged
Conversation
- Cost estimates bill everything in total_tokens beyond the prompt as output, so thinking tokens reported outside completion_tokens (Gemini) are counted. OpenAI's reasoning (already inside completion_tokens) is not double-counted. Logs show a Thinking Tokens figure when present. - Gemini moves from the OpenAI-compatible endpoint to the native Interactions API (v1beta/interactions, x-goog-api-key) so images can be sent with resolution "low" (280 tokens vs 1,120 default). Uses store:false, parses model_output steps, maps status incomplete/failed, and reads total_thought_tokens. Thinking level is left at the model default (minimal for Flash-Lite) instead of forcing "low". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
total_tokensbeyond the prompt as output, so thinking tokens reported outsidecompletion_tokens(Gemini) are counted. OpenAI reasoning (already insidecompletion_tokens) isn't double-counted. Logs show a Thinking Tokens figure when present; the monthly spending limit uses the corrected amounts. A real Gemini log row re-prices from $0.000324 to $0.000489.v1beta/interactions,x-goog-api-key) so images are sent withresolution: "low"(280 tokens vs the 1,120 default). Requests usestore: false. Parsesmodel_outputsteps, mapsincomplete/failedstatus, readstotal_thought_tokens. Thinking level is left at the model default (minimal for Flash-Lite) instead of forcinglow.Testing
store:false, inline base64,resolution: low), text parsing, truncation/failure statuses, cost with thinking tokens; OpenAI and DeepInfra requests and costs unchanged (13/13 pass)🤖 Generated with Claude Code