Skip to content

feat(api): report reasoning token usage - #1490

Open
sufubao wants to merge 1 commit into
ModelTC:mainfrom
sufubao:fix/reasoning-token-usage
Open

feat(api): report reasoning token usage#1490
sufubao wants to merge 1 commit into
ModelTC:mainfrom
sufubao:fix/reasoning-token-usage

Conversation

@sufubao

@sufubao sufubao commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add completion_tokens_details.reasoning_tokens to Chat Completions usage
  • count generated token IDs through the configured reasoning parser for streaming and non-streaming responses, including n-choice aggregation
  • propagate the count to Responses API output_tokens_details.reasoning_tokens
  • document the response fields in the English and Chinese reasoning parser guides

Motivation

LightLLM already separates reasoning text, but its usage model did not expose the number of reasoning tokens. Downstream gateways therefore reported reasoning_tokens as zero even when the response contained reasoning.

This follows the current vLLM main design: retain generated token IDs, let the active reasoning parser count them, and populate completion token details only when a reasoning parser is configured.

Verification

  • black --check --line-length 120 on all changed Python files
  • flake8 on all changed Python files

@sufubao
sufubao force-pushed the fix/reasoning-token-usage branch from 51be1ae to 415c3f3 Compare August 24, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant