8 Commits
Author SHA1 Message Date
Alex Castillo 4932b8be2c fix(ai): read usage from response.incomplete in OpenAI Responses streams
extractOpenAiResponses only took response.usage from response.completed, so a
stream cut by max_output_tokens (response.incomplete) lost its usage and fell
back to estimateUsage over the whole SSE text, over-counting cost and budget.
Read response.usage from any event that carries it.
2026-11-09 04:04:08 -04:00
Alex Castillo 64c9c85fc1 fix(ai): count Gemini toolUsePromptTokenCount as input tokens
Gemini reports the tokens of tool results (Google Search, URL context) in usageMetadata.toolUsePromptTokenCount, separate from promptTokenCount. The extractor ignored it, so usage and cost were under-counted.
2026-11-05 19:02:15 -04:00
Alex Castillo 61c89834e8 fix(ai-gateway): stop subtracting Bedrock Converse cache reads from inputTokens
With prompt caching enabled, Bedrock reports inputTokens as the non-cached input only; cacheReadInputTokens and cacheWriteInputTokens are separate counters. Subtracting the cache reads again undercounted promptTokens (clamped to 0) in both the JSON and the stream-scan paths.
2026-11-02 19:57:39 -05:00
Owen e65a79cc48 Rename to v1_models and use with openai as well 2026-08-20 16:01:07 -04:00
Owen bafbf6e096 Add anthropic_models capability 2026-08-20 14:28:19 -04:00
Owen ef051c2f8c Dont count usage when the response was not successful 2026-08-19 15:59:01 -04:00
Owen bc2f291352 normalize the requests to also store in the log for viewing later 2026-08-11 14:45:25 -04:00
Owen 12056aebc6 Add basic cost calculations for testing 2026-08-07 13:54:32 -04:00