Describe the bug
When a request to an Anthropic model uses extended thinking ("thinking": {"type": "adaptive"} with output_config.effort, or the older "thinking": {"type": "enabled", "budget_tokens": N} shape), Anthropic's native API reports a distinct usage.output_tokens_details.thinking_tokens count in its response. GoModel does not capture this into the usage entry's raw_data, so how many output tokens were spent thinking is invisible in GoModel's usage and cost accounting - only the total output_tokens is recorded.
Root cause: anthropicUsage (internal/providers/anthropic/types.go, around lines 99-104) does not parse output_tokens_details at all, so the field is silently dropped at JSON unmarshal time before buildAnthropicRawUsage (internal/providers/anthropic/anthropic.go, around lines 344-356) ever runs. That function currently only extracts cache_creation_input_tokens and cache_read_input_tokens into raw_data.
GoModel version
v0.1.68 (commit 9d54827, built 2026-08-03)
Steps To Reproduce
- Start GoModel with an ANTHROPIC_API_KEY configured.
- POST to /v1/chat/completions with a Claude model, e.g.:
{ "model": "anthropic/", "max_tokens": 2000, "messages": [...], "thinking": {"type": "adaptive"}, "output_config": {"effort": "high"} }
- Inspect the resulting usage entry's raw_data column (e.g. via sqlite: SELECT raw_data FROM usage ORDER BY rowid DESC LIMIT 1;) - it is empty.
- For comparison, send the same prompt directly through GoModel's Anthropic passthrough route (/p/anthropic/v1/messages) - the raw upstream response includes usage.output_tokens_details.thinking_tokens, confirming Anthropic does report this distinctly and GoModel is dropping it during translation, not that Anthropic omits it.
Screenshots/Logs
Direct passthrough response for the same kind of prompt:
"usage": {
"input_tokens": 31,
"output_tokens": 311,
"output_tokens_details": {
"thinking_tokens": 27
}
}
The corresponding /v1/chat/completions usage entry's raw_data is empty.
Additional context
Fix looks well scoped: add an OutputTokensDetails field (with a ThinkingTokens int, tagged json:"thinking_tokens") to anthropicUsage, and add a corresponding key (for example completion_thinking_tokens) to buildAnthropicRawUsage when present, following the same pattern already used for the two cache-token fields. Good first issue.
Describe the bug
When a request to an Anthropic model uses extended thinking (
"thinking": {"type": "adaptive"}withoutput_config.effort, or the older"thinking": {"type": "enabled", "budget_tokens": N}shape), Anthropic's native API reports a distinctusage.output_tokens_details.thinking_tokenscount in its response. GoModel does not capture this into the usage entry'sraw_data, so how many output tokens were spent thinking is invisible in GoModel's usage and cost accounting - only the total output_tokens is recorded.Root cause:
anthropicUsage(internal/providers/anthropic/types.go, around lines 99-104) does not parseoutput_tokens_detailsat all, so the field is silently dropped at JSON unmarshal time beforebuildAnthropicRawUsage(internal/providers/anthropic/anthropic.go, around lines 344-356) ever runs. That function currently only extractscache_creation_input_tokensandcache_read_input_tokensinto raw_data.GoModel version
v0.1.68 (commit 9d54827, built 2026-08-03)
Steps To Reproduce
{ "model": "anthropic/", "max_tokens": 2000, "messages": [...], "thinking": {"type": "adaptive"}, "output_config": {"effort": "high"} }
Screenshots/Logs
Direct passthrough response for the same kind of prompt:
The corresponding /v1/chat/completions usage entry's raw_data is empty.
Additional context
Fix looks well scoped: add an OutputTokensDetails field (with a ThinkingTokens int, tagged json:"thinking_tokens") to anthropicUsage, and add a corresponding key (for example completion_thinking_tokens) to buildAnthropicRawUsage when present, following the same pattern already used for the two cache-token fields. Good first issue.