puter
puter copied to clipboard
feat: meter Gemini thinking tokens and grounding requests
Summary
- Thinking tokens: Extracted from standard completion tokens to ensure they are billed accurately at the correct model specific rate.
- Grounding requests: Added flat-fee metering for Google Search by tracking
grounding_metadataacross both streaming and non-streaming responses. - Pricing updates: Corrected stale rates for Gemini 2.5 Flash output, cached tokens, thinking tokens, and grounding requests.
Closes #3132
Test
- All pre-existing tests pass.
- 5 unit tests for the corresponding changes have been added
- 4 pre-existing test assertions updated to include
thinking_tokens: 0andgrounding_requests: 0in the expected usage shapes
are thinking tokens not already included in output tokens in the usage object?
are thinking tokens not already included in output tokens in the usage object?
Yes they are already included but we split them because they are billed at different rates, like this: thinking_rate*thinking_tokens + standard_rate*(completion_tokens - thinking_tokens)
@ProgrammerIn-wonderland is this mergable?