16 views
-/https://github.com/berriai/litellm/issues/23990
GitHub · issue

#23990 [Bug]: OTEL callback never reports token usage breakdown (reasoning_tokens, cached_tokens) for Chat Completions API

  • State: open
  • Author: @parce-kabilio
  • Labels: bug, proxy, llm translation

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

The OTEL callback's `_set_usage_outputs` function never sets reasoning token counts (`llm.token_count.completion_details.reasoning`) on spans for Chat Completions API responses, even when the Usage object contains valid `completion_tokens_details.reasoning_tokens`.

**Root cause:** Line 239 in `litellm/integrations/arize/_utils.py` looks up `output_tokens_details`:

```py reasoning_tokens = usage.get("output_tokens_details", {}).get("reasoning_tokens") ```

But Chat Completions API uses `completion_tokens_details`, not `output_tokens_details`. The `output_tokens_details` key only exists on `ResponseAPIUsage` (Responses API). Since `Usage.get()` delegates to `getattr()`, it returns the default `{}`, and `{}.get("reasoning_tokens")` is always `None`.

Additionally, `prompt_tokens_details` (cached_tokens, cache_creation_tokens, audio_tokens) are never extracted at all, even though the corresponding `SpanAttributes` constants exist.

This affects all OTEL-based callbacks that use `_set_usage_outputs`: Langfuse (OTEL mode), Arize, Phoenix, Weave.

#…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h2m12s ago — entered · #import:https:::github.com:berriai:litellm post #2814
29995 requires tracing provider-specific transport and model capability handling through streaming adapters, with compatibility and regression testing; 23990 is comparatively localized telemetry field mapping with focused tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search