mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-23 15:42:12 +03:00
fix(analytics): classify opencode-go as a flat-rate subscription (#11199)
Validated on the combined batch board over tip c92bd40b: static gates clean (changelog, file-size 158 frozen, complexity 2626<=2774, cognitive 1183<=1223, dead-code 409<=416), typecheck:core clean, 70 focused tests green (PR suites 49/49 + auth/combo neighbors 21/21).
opencode-go joins FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS — cost analytics stop pricing a flat 0 subscription at metered aggregator rates (3.35 reported vs 0 actual). Same pattern as #10774. Fixes #11149. Thank you @pacocartones!
This commit is contained in:
1
changelog.d/fixes/11149-opencode-go-flat-rate.md
Normal file
1
changelog.d/fixes/11149-opencode-go-flat-rate.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(analytics):** `opencode-go` is now classified as a flat-rate subscription, so cost analytics shows $0 for it instead of billing every call at the underlying model’s metered rate — it resells GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x under one flat monthly fee, which made the overstatement large rather than marginal ([#11149](https://github.com/diegosouzapw/OmniRoute/pull/11149)) — thanks @electrumguy
|
||||
@@ -46,6 +46,11 @@ const FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS: ReadonlySet<string> = new Set([
|
||||
"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)
|
||||
// OpenCode Go subscription (https://opencode.ai/go) — a flat monthly fee. It is an
|
||||
// aggregator reselling GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x, so
|
||||
// per-token rows price each call at the UNDERLYING model's metered rate and the
|
||||
// analytics overstatement is large rather than marginal (#11149).
|
||||
"opencode-go",
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ test("isFlatRateProvider: dedicated subscription / coding-plan providers are fla
|
||||
"glm-cn",
|
||||
"claude",
|
||||
"cc",
|
||||
"opencode-go",
|
||||
]) {
|
||||
assert.equal(isFlatRateProvider(id), true, `${id} should be flat-rate`);
|
||||
}
|
||||
@@ -83,6 +84,27 @@ test("computeCostFromPricing: opt-in only — flat-rate provider WITHOUT the fla
|
||||
assert.equal(computeCostFromPricing(PRICING, TOKENS, { provider: "chatgpt-web" }), 3);
|
||||
});
|
||||
|
||||
test("#11149: opencode-go is a flat-rate subscription, not metered", () => {
|
||||
// opencode-go (https://opencode.ai/go) is a $10/month flat subscription that
|
||||
// resells GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x. Because it is
|
||||
// an aggregator, every call was priced at the UNDERLYING model's metered rate,
|
||||
// so the overstatement is large rather than marginal (a reported ~$13.35 for a
|
||||
// month actually billed at $10 flat). It is api-key auth, so it is not covered
|
||||
// by the dynamic WEB_COOKIE_PROVIDERS branch and needs the explicit id.
|
||||
assert.equal(isFlatRateProvider("opencode-go"), true);
|
||||
assert.equal(
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "opencode-go", flatRateAsZero: true }),
|
||||
0
|
||||
);
|
||||
// Still opt-in: without the flag the per-request estimate is unchanged.
|
||||
assert.equal(computeCostFromPricing(PRICING, TOKENS, { provider: "opencode-go" }), 3);
|
||||
});
|
||||
|
||||
test("#11149: sibling opencode ids keep their own billing semantics", () => {
|
||||
// Only the Go subscription is flat-rate. The keyless `opencode` provider is a
|
||||
// different id and must not be swept in by a prefix-style match.
|
||||
assert.equal(isFlatRateProvider("opencode"), false);
|
||||
});
|
||||
test("computeCostFromPricing: metered provider with the flag still estimates", () => {
|
||||
assert.equal(
|
||||
computeCostFromPricing(PRICING, TOKENS, { provider: "openai", flatRateAsZero: true }),
|
||||
|
||||
Reference in New Issue
Block a user