Skip to content

Reasoning token is not included in the total cost. #264

@kerthcet

Description

@kerthcet

What happened:

From claude:

How Traceloop/OpenTelemetry Treats Tokens

  Based on the OpenTelemetry instrumentation code:

  # From API response.usage:
  usage = {
      "prompt_tokens": 3891,           # → gen_ai.usage.input_tokens
      "completion_tokens": 1532,        # → gen_ai.usage.output_tokens
      "total_tokens": 11738,
      "completion_tokens_details": {
          "reasoning_tokens": 6315      # → gen_ai.usage.reasoning_tokens
      }
  }

  Key findings:

  1. ✅ prompt_tokens (input_tokens) does NOT include reasoning tokens
  2. ✅ reasoning_tokens is extracted from completion_tokens_details.reasoning_tokens
  3. ✅ They are stored as SEPARATE attributes: gen_ai.usage.input_tokens and gen_ai.usage.reasoning_tokens
  4. ✅ Your ClickHouse query confirmed: total_tokens = input + output + reasoning

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCategorizes issue or PR as related to a bug.needs-priorityIndicates a PR lacks a label and requires one.needs-triageIndicates an issue or PR lacks a label and requires one.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions