Skip to content

OpenAI reasoning tokens double-counted in cost calculation #17566

@killerdejavu

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.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions