Back to Codexbar

Model pricing metadata

docs/model-pricing.md

0.53.01.8 KB
Original Source

Model pricing metadata

CodexBar uses models.dev as an additive pricing source alongside bundled fallback rates.

Source and cache

  • Source API: https://models.dev/api.json
  • No API key is required.
  • Local cache: ~/Library/Caches/CodexBar/model-pricing/models-dev-v1.json
  • TTL: 24 hours

The pipeline lets future scanner code read the last valid cache synchronously with ModelsDevPricingPipeline.lookup and refresh stale metadata separately with ModelsDevPricingPipeline.refreshIfNeeded. If a refresh fails, the last valid cache remains usable.

Lookup rules

Pricing is scoped by provider id and model id. This prevents two providers with the same model id or display name from sharing pricing accidentally.

Local cost scanners preserve that scope when selecting a catalog:

  • Bare Codex/OpenAI model IDs use provider id openai; approved provider-qualified routes stay on their route, and unknown prefixes remain unpriced.
  • Recognizable bare Claude-session model families use their first-party vendor catalog, including Anthropic, OpenAI, Google, Moonshot/Kimi, MiniMax, and DeepSeek.
  • Other bare Claude-session IDs are priced only when exactly one selected first-party catalog matches. Ambiguous cross-vendor matches remain unpriced.
  • Provider-qualified Claude-session IDs stay on an approved explicit route and never fall through to another vendor.
  • Vertex AI Claude logs: models.dev provider id google-vertex-anthropic

Units

models.dev publishes costs as USD per 1M tokens. CodexBar converts those to USD per token in the metadata layer:

text
perToken = modelsDevCost / 1_000_000

When models.dev includes cost.context_over_200k, CodexBar parses those values as the above-200k-token pricing lane and converts them with the same per-1M-token rule.