Skip to content

fix(pricing): GPT-5.3 Codex resolves to $0.00 — filter github_copilot + inject overrides#207

Merged
junhoyeo merged 7 commits intomainfrom
fix/gpt-5.3-codex-pricing
Feb 18, 2026
Merged

fix(pricing): GPT-5.3 Codex resolves to $0.00 — filter github_copilot + inject overrides#207
junhoyeo merged 7 commits intomainfrom
fix/gpt-5.3-codex-pricing

Conversation

@junhoyeo
Copy link
Owner

@junhoyeo junhoyeo commented Feb 18, 2026

Summary

  • Filter github_copilot/ entries from LiteLLM data — subscription-based $0.00 pricing poisons per-token cost estimation (e.g. github_copilot/gpt-5.3-codex → $0.00/$0.00)
  • Inject hardcoded pricing overrides for gpt-5.3, gpt-5.3-codex, gpt-5.3-codex-spark at $1.75/$14.00 per 1M tokens ($0.175 cache read) — sourced from Cursor docs + llm-stats.com corroboration
  • Overrides use or_insert_with — they won't clobber future LiteLLM/OpenRouter entries once official API pricing lands (LiteLLM PR #20552 pending)
  • 6 new unit tests covering filter, override injection, and lookup

Root Cause

tokscale pricing "gpt-5.3-codex" matched github_copilot/gpt-5.3-codex from LiteLLM data, which reports $0.00/$0.00 (subscription-based, meaningless for cost estimation). GPT-5.3 Codex is not yet on the OpenAI API, so no legitimate entry exists in either LiteLLM or OpenRouter.

Test Results

cargo test166 passed, 0 failed, 1 ignored (pre-existing sqlite test)


Closes #199, Closes #172, Closes #204, Closes #205, Closes #206


Summary by cubic

Fixes $0.00 pricing for GPT-5.3 Codex by filtering subscription-only GitHub Copilot entries and adding Cursor-priced overrides for the GPT-5.3 family. Docs now explain Cursor pricing as a third lookup source; overrides run after exact/prefix and before fuzzy, and the CLI labels them as Cursor.

  • Bug Fixes

    • Exclude LiteLLM entries with prefix github_copilot/ to avoid zero-cost matches.
    • Apply Cursor overrides after exact/prefix matches; skip with --provider; prefer upstream when present; handle version-normalized and provider-prefixed inputs and tier suffixes (e.g., gpt-5-3-codex → gpt-5.3-codex, openai/gpt-5.3-codex, -high); CLI shows “Cursor”; share compute_cost.
  • New Features

    • Add Cursor pricing for gpt-5.3, gpt-5.3-codex, and gpt-5.3-codex-spark at $1.75/$14 per 1M tokens with $0.175 cache read; tests cover filtering, priority ordering, forced-source behavior, version normalization, provider-prefixed inputs, tier suffix stripping, and cost calculation; updated EN/KO/JA/ZH READMEs to document Cursor pricing and lookup order.

Written for commit 4989b0e. Summary will update on new commits.

…overrides

- Exclude github_copilot/ prefix from LiteLLM data (subscription-based
  $0.00 pricing poisons per-token cost estimation)
- Inject hardcoded pricing overrides for gpt-5.3, gpt-5.3-codex, and
  gpt-5.3-codex-spark at $1.75/$14.00 per 1M tokens with $0.175 cache
  read (sourced from Cursor docs + llm-stats.com corroboration)
- Overrides use or_insert_with to avoid clobbering future LiteLLM/OpenRouter
  entries once they add official API pricing
- Add 6 unit tests covering filter, override injection, and lookup

Closes #199, closes #172
Refs #204, #205
@vercel
Copy link
Contributor

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokscale Ready Ready Preview, Comment Feb 18, 2026 7:10am

Request Review

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f249d32a63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Overrides were injected as bare keys into the LiteLLM HashMap, which
meant exact_match_litellm would return them before OpenRouter entries
were checked. If OpenRouter added openai/gpt-5.3-codex with real API
pricing, the hardcoded override would shadow it.

Now overrides live in a separate fallback_overrides HashMap on
PricingService, checked only AFTER both LiteLLM and OpenRouter
return no match. Tests verify fallback yields to both LiteLLM bare
keys and OpenRouter provider-prefixed entries.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/src/pricing/mod.rs">

<violation number="1" location="packages/core/src/pricing/mod.rs:99">
P2: lookup_with_source now returns fallback pricing even when a specific source is forced, so `lookup_pricing(..., Some("litellm"))` can succeed with a "Fallback" source instead of returning an error. This violates the forced-source contract and can mislead callers.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…per, fix CLI label

- Fallback overrides no longer fire when --provider is set; forced source
  miss correctly returns None (propagates error to CLI)
- Extract compute_cost() shared between PricingLookup and PricingService
  to prevent cost formula drift
- CLI now displays 'Fallback' (yellow) instead of mislabeling as OpenRouter
- Add test_fallback_skipped_when_force_source_set
Fallback overrides are now checked after prefix matches but before fuzzy
matching inside PricingLookup, preventing fuzzy from resolving gpt-5.3-codex
to wrong models like gpt-5.1-codex-mini. Also restores doc comments with
@keep annotations for non-obvious filtering and priority ordering logic.

Closes #204, closes #205
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/src/pricing/lookup.rs">

<violation number="1" location="packages/core/src/pricing/lookup.rs:243">
P2: Fallback pricing only checks the raw model_id, so normalized variants (e.g., gpt-5-3-codex → gpt-5.3-codex) won’t match fallback even though version/model normalization is already applied for other sources. Apply the same normalization before fallback to keep behavior consistent.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…n gap

Rename all internal "fallback" naming to "cursor" since the data source
is Cursor model pricing. Also fix a bug where version-normalized queries
(e.g. gpt-5-3-codex → gpt-5.3-codex) would skip Cursor overrides and
fall through to fuzzy matching, potentially resolving to wrong models.
…ntified tests

openai/gpt-5.3-codex was resolving to perplexity/openai/gpt-4o-mini ($0.00)
because exact_match_cursor did not strip provider prefixes. Now extracts the
model part after "/" and checks Cursor overrides, matching the existing
openrouter_model_part pattern. Added 3 tests for provider-prefix resolution,
upstream precedence, and tier suffix stripping.
@junhoyeo
Copy link
Owner Author

Pricing Resolution Verification (49/49 models pass)

All models used on this machine resolve correctly after the fix. GPT-5.3 edge case coverage:

Query Matched Key Source Input/1M Output/1M
gpt-5.3 gpt-5.3 Cursor $1.75 $14.00
gpt-5.3-codex gpt-5.3-codex Cursor $1.75 $14.00
gpt-5.3-codex-spark gpt-5.3-codex-spark Cursor $1.75 $14.00
gpt-5.3-codex-high gpt-5.3-codex Cursor $1.75 $14.00
gpt-5-3-codex gpt-5.3-codex Cursor $1.75 $14.00
openai/gpt-5.3-codex gpt-5.3-codex Cursor $1.75 $14.00
GPT-5.3-CODEX gpt-5.3-codex Cursor $1.75 $14.00

Edge cases verified:

  • Tier suffix (-high, -xhigh, -low) → strips suffix, resolves to base model via Cursor
  • Version normalization (gpt-5-3-codexgpt-5.3-codex) → normalizes before Cursor check
  • Provider prefix (openai/gpt-5.3-codex) → extracts model part, resolves via Cursor
  • Case insensitivity (GPT-5.3-CODEX) → lowercased before lookup
  • Upstream precedence → LiteLLM/OpenRouter exact/prefix matches always win over Cursor overrides

170 tests pass (cargo test), zero regressions on existing models.

Update lookup strategy (now 7 steps), pricing section, and features
bullet across all 4 READMEs (EN, KO, JA, ZH-CN) to reflect the new
Cursor pricing override layer for models not yet in LiteLLM/OpenRouter.
@junhoyeo junhoyeo merged commit 4be5f7c into main Feb 18, 2026
13 checks passed
@junhoyeo junhoyeo deleted the fix/gpt-5.3-codex-pricing branch February 18, 2026 07:22
Yeachan-Heo pushed a commit to Yeachan-Heo/tokscale that referenced this pull request Feb 18, 2026
fix(pricing): GPT-5.3 Codex resolves to $0.00 — filter github_copilot + inject overrides
Co-authored-by: Junho Yeo <i@junho.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant