Skip to content

OpenAI reasoning tokens double-counted in cost calculation #17566

Closed

Description

@killerdejavu

Bug: For OpenAI reasoning models (e.g. gpt-4o, o1, o3), getUsage in session/index.ts adds reasoning tokens as a separate cost term on top of output tokens. But OpenAI's reasoning tokens are already a subset of completion_tokens — so they get billed twice.

Example with gpt-5.4-pro:

  • Input: 14,746 tokens @ $30/M = $0.44238
  • Output: 1,944 tokens @ $180/M = $0.34992
  • Reasoning: 1,360 tokens (subset of output)

Actual charge: $0.7923. OpenCode reports: ~$1.04 (overstated).

Anthropic bills thinking tokens separately (not included in outputTokens), so that provider is correct. The extra reasoning cost term should only apply to Anthropic/Bedrock.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 15, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. rekram1-node commented on May 27, 2026

    @rekram1-node
    Contributor

    believe this is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions