feat(pricing): add custom pricing overrides#549
Open
ben-vargas wants to merge 1 commit into
Open
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved 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="README.md">
<violation number="1" location="README.md:369">
P2: README lookup strategy should document that provider forcing changes custom override precedence</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| 5. **Provider Prefix Matching** - Tries common prefixes (`anthropic/`, `openai/`, etc.) | ||
| 6. **Cursor Model Pricing** - Hardcoded pricing for models not yet in LiteLLM/OpenRouter (e.g., `gpt-5.3-codex`) | ||
| 7. **Fuzzy Matching** - Word-boundary matching for partial model names | ||
| 1. **Custom Pricing Overrides** - Exact user-defined entries from `~/.config/tokscale/custom-pricing.json` |
Contributor
There was a problem hiding this comment.
P2: README lookup strategy should document that provider forcing changes custom override precedence
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At README.md, line 369:
<comment>README lookup strategy should document that provider forcing changes custom override precedence</comment>
<file context>
@@ -357,19 +357,55 @@ tokscale pricing "grok-code"
-5. **Provider Prefix Matching** - Tries common prefixes (`anthropic/`, `openai/`, etc.)
-6. **Cursor Model Pricing** - Hardcoded pricing for models not yet in LiteLLM/OpenRouter (e.g., `gpt-5.3-codex`)
-7. **Fuzzy Matching** - Word-boundary matching for partial model names
+1. **Custom Pricing Overrides** - Exact user-defined entries from `~/.config/tokscale/custom-pricing.json`
+2. **Exact Match** - Direct lookup in LiteLLM/OpenRouter databases
+3. **Alias Resolution** - Resolves friendly names (e.g., `big-pickle` → `glm-4.7`)
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a local
custom-pricing.jsonoverride layer for exact model pricing fixes. Overrides are loaded from tokscale's config directory, checked before LiteLLM/OpenRouter/Cursor fallback pricing, and use exact matching only so user-specified accounting fixes cannot fuzzy-match into unrelated models.This is one possible implementation for #548. In the age of agentic development, maintainers may reasonably choose to have their own agents design or implement a different solution if the issue is accepted; this PR is intended as a concrete, tested example of how the feature could work.
What changed
crates/tokscale-core/src/pricing/custom.rsfor loading and validatingcustom-pricing.json.input_cost_per_million_tokens, plus LiteLLM-compatible per-token fields such asinput_cost_per_token./models/normalization, before falling through to the current pricing resolver.--provider litellmand--provider openrouterbypass custom overrides, while--provider customchecks only custom overrides.tokscale pricing list-overrideswith text and JSON output.AI disclosure
This PR was AI generated with
GPT-5.5 (xhigh)and reviewed iteratively withOpus 4.7 (Max). I manually tested the resulting worktree and pushed the branch from my fork.Validation
cargo test --workspace cargo clippy --workspace --all-targets -- -D warnings cargo build --release --bin tokscaleAlso smoke-tested a Fireworks Kimi K2.6 Turbo override:
which reports the custom
$2.00 / $8.00 / $0.30per-1M pricing.Summary by cubic
Add local custom pricing overrides via
custom-pricing.jsonso users can fix or pin model prices. Overrides take precedence overLiteLLM/OpenRouterin lookups and cost calculations, unless a provider is explicitly forced.~/.config/tokscale/custom-pricing.json(orTOKSCALE_CONFIG_DIR).input_cost_per_million_tokens) and LiteLLM-style per-token fields (e.g.,input_cost_per_token)./models/match → existing sources (LiteLLM,OpenRouter,Cursor) → fuzzy.--provider customchecks only custom,--provider litellm|openrouterbypasses custom.tokscale pricing list-overrides(text or--json) to inspect loaded overrides.tokscaleafter editing the file.Written for commit 1417630. Summary will update on new commits.