mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 14:12:59 +03:00
fix(analytics): treat Claude Code (claude/cc) as a flat-rate subscription provider (#10773) (#10774)
Merged via merge-train (release/v3.8.50, batch1 2026-08-20) — static gates (typecheck/file-size/complexity/cognitive/changelog) green on the combined tree; test:unit reds observed in the boarded run were verified pre-existing on the pure release tip (unrelated flake), not caused by this PR. Thanks for the contribution!
This commit is contained in:
1
changelog.d/fixes/10774-claude-code-flat-rate.md
Normal file
1
changelog.d/fixes/10774-claude-code-flat-rate.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(analytics):** Claude Code (`claude`/`cc`) is a flat-rate subscription, so cost analytics reports `$0` for it instead of estimating Anthropic list prices — the metered `anthropic` API keeps its real cost, and budget/quota/routing still estimate as before ([#10774](https://github.com/diegosouzapw/OmniRoute/pull/10774)) — thanks @electrumguy
|
||||
@@ -31,8 +31,9 @@ import { WEB_COOKIE_PROVIDERS } from "@/shared/constants/providers/web-cookie";
|
||||
* its analytics cost is intentional, not an artifact), `byteplus` (BytePlus
|
||||
* ModelArk is a metered inference host, billed per token — zeroing it would hide
|
||||
* real cost), `minimax-cn` (the metered Minimax China API, distinct from the
|
||||
* `minimax` "Minimax Coding" plan), and `glm-thinking` (metered tier, distinct
|
||||
* from the `glm` Coding plan).
|
||||
* `minimax` "Minimax Coding" plan), `glm-thinking` (metered tier, distinct
|
||||
* from the `glm` Coding plan), and `anthropic` (the metered Anthropic API,
|
||||
* distinct from the `claude`/`cc` Claude Code plan below).
|
||||
*/
|
||||
const FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS: ReadonlySet<string> = new Set([
|
||||
"minimax", // "Minimax Coding" plan
|
||||
@@ -43,6 +44,8 @@ const FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS: ReadonlySet<string> = new Set([
|
||||
"qwen-cloud-token-plan", // Qwen Cloud Token Plan
|
||||
"glm", // GLM Coding plan
|
||||
"glm-cn", // GLM Coding (China) plan
|
||||
"claude", // Claude Code plan (OAuth-only — a Claude Pro/Max subscription)
|
||||
"cc", // Claude Code plan (alias id — same connection, shares the `cc` pricing rows)
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,8 @@ test("isFlatRateProvider: dedicated subscription / coding-plan providers are fla
|
||||
"qwen-cloud-token-plan",
|
||||
"glm",
|
||||
"glm-cn",
|
||||
"claude",
|
||||
"cc",
|
||||
]) {
|
||||
assert.equal(isFlatRateProvider(id), true, `${id} should be flat-rate`);
|
||||
}
|
||||
@@ -36,7 +38,8 @@ test("isFlatRateProvider: case-insensitive + trimmed", () => {
|
||||
test("isFlatRateProvider: metered / cost-tracked providers are NOT flat-rate (no hidden cost)", () => {
|
||||
// codex/cx = OmniRoute actively tracks Codex token cost (Fast-tier multipliers,
|
||||
// GPT-5.x pricing) and Codex can be a metered account; byteplus = metered ModelArk;
|
||||
// minimax-cn = metered China API; glm-thinking = metered tier.
|
||||
// minimax-cn = metered China API; glm-thinking = metered tier; anthropic = the
|
||||
// metered Anthropic API, distinct from the `claude`/`cc` Claude Code plan.
|
||||
for (const id of [
|
||||
"openai",
|
||||
"anthropic",
|
||||
@@ -68,6 +71,11 @@ test("computeCostFromPricing: flat-rate provider with flatRateAsZero → $0", ()
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "minimax", flatRateAsZero: true }),
|
||||
0
|
||||
);
|
||||
// Claude Code is billed by the Pro/Max subscription, never per token.
|
||||
assert.equal(
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "claude", flatRateAsZero: true }),
|
||||
0
|
||||
);
|
||||
});
|
||||
|
||||
test("computeCostFromPricing: opt-in only — flat-rate provider WITHOUT the flag still estimates", () => {
|
||||
@@ -85,4 +93,9 @@ test("computeCostFromPricing: metered provider with the flag still estimates", (
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "byteplus", flatRateAsZero: true }),
|
||||
3
|
||||
);
|
||||
// The metered Anthropic API keeps its real cost — only the Claude Code plan is flat-rate.
|
||||
assert.equal(
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "anthropic", flatRateAsZero: true }),
|
||||
3
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user