mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-16 07:33:06 +08:00
The WS v2 passthrough relay only read output_tokens_details.image_tokens, so image generation over WebSocket billed image input tokens at the text input rate and ignored the hosted response.tool_usage.image_gen breakdown that the HTTP Responses path already merges (extractOpenAIUsageFromJSONBytes + mergeHostedImageGenToolUsage). The relay now reads image input tokens from input_tokens_details or prompt_tokens_details, fills missing image input/output counters from response.tool_usage.image_gen (usage values keep precedence), and carries ImageInputTokens per turn and in the session aggregate into the OpenAIForwardResult used for billing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>