Describe the bug
When an upstream model API returns a successful response but explicitly sets all token usage metrics to 0 (e.g., "total_tokens": 0), the request is entirely excluded from CLIProxyAPI's usage statistics aggregation.
While it is correct to filter out empty chunks from streams to prevent spam, a completed request that happens to report 0 tokens should still be recorded as a valid request/transaction in the usage statistics (so the request count increments), rather than being silently dropped.
Steps to reproduce
- Configure a provider that returns
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0} in its successful JSON response.
- Enable
usage-statistics-enabled: true in the config.
- Make a chat completion request to this model.
- Observe that the token/request usage in the management dashboard remains unchanged for this key/model.
Expected behavior
The request should be recorded in the in-memory usage statistics (incrementing the request count) even if the token delta is 0.
Related PR
A fix for this has been submitted in PR #2272, which adds the missing ensurePublished safety calls to the affected executors.
Describe the bug
When an upstream model API returns a successful response but explicitly sets all token usage metrics to
0(e.g.,"total_tokens": 0), the request is entirely excluded from CLIProxyAPI's usage statistics aggregation.While it is correct to filter out empty chunks from streams to prevent spam, a completed request that happens to report
0tokens should still be recorded as a valid request/transaction in the usage statistics (so the request count increments), rather than being silently dropped.Steps to reproduce
"usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0}in its successful JSON response.usage-statistics-enabled: truein the config.Expected behavior
The request should be recorded in the in-memory usage statistics (incrementing the request count) even if the token delta is
0.Related PR
A fix for this has been submitted in PR #2272, which adds the missing
ensurePublishedsafety calls to the affected executors.