Gateway model discovery pricing is ignored by /usage

Status Open
Reported on v2.1.238
Maintainer reply None cached
Activity 1 comment · opened Aug 21, 2026

Bug description

Claude Code's gateway model discovery reads only data[].id and optional display_name. It discards a gateway's per-model pricing metadata, so /usage applies the built-in fallback tariff to every custom model and reports an inaccurate cost.

Claude Code 2.1.238 currently displays:

Total cost: $0.3181 (costs may be inaccurate due to usage of unknown models)
stealth/ox-alpha: 63.0k input, 134 output ... ($0.3181)

The gateway's authenticated /v1/models row publishes the model's actual input, output, cache-read, and cache-write prices, and its inference response includes provider-accounted cost details. Neither source reaches Claude Code's local cost table.

Steps to reproduce

  1. Configure ANTHROPIC_BASE_URL for an Anthropic-compatible gateway.
  2. Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1.
  3. Select a gateway model whose price differs from Claude's built-in fallback tariff.
  4. Send one request and open /usage.

Expected behavior

Gateway discovery should have a documented optional pricing shape that populates the same per-model cost table /usage uses. At minimum it should support input, output, cache read, cache write, and web-search rates with explicit units.

Actual behavior

The documented discovery response consumes only id and display_name. The installed 2.1.238 bundle validates the same two fields, strips the rest, and falls back to the default built-in tariff for unknown models while marking the estimate inaccurate.

Environment

  • Claude Code 2.1.238
  • macOS arm64
  • Anthropic-compatible custom gateway through ANTHROPIC_BASE_URL
  • Gateway discovery enabled

Additional context

The official gateway protocol already makes /v1/models the model-discovery boundary. Extending that response is safer than asking launchers to mutate the undocumented additionalModelCostsCache in ~/.claude.json, and lets /usage stay accurate after an in-session /model switch.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗