Skip to content

Negative text_output_tokens when using grok-4-fast-reasoning #11487

@williamlmao

Description

@williamlmao

Description

I noticed that grok-4-fast-reasoning would result in a negative number in the usage field. I logged a request, here is the raw:

"{"prompt_tokens":279,"completion_tokens":6,"total_tokens":374,"prompt_tokens_details":{"text_tokens":279,"audio_tokens":0,"image_tokens":0,"cached_tokens":149},"completion_tokens_details":{"reasoning_tokens":89,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}"

In the usage field, we end up with "-83" text_output_tokens which is the 6 completion tokens minus the 89 reasoning tokens. Shouldn't this actually be 6, text_output_tokens, 89 reasoning tokens, and 95 total output tokens?

AI SDK Version

"ai": "^6.0.3",
"@ai-sdk/xai": "3.0.1",

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelprovider/communitysupport

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions