diff --git a/changelog.d/fixes/11149-opencode-go-flat-rate.md b/changelog.d/fixes/11149-opencode-go-flat-rate.md new file mode 100644 index 0000000000..7aa63ad455 --- /dev/null +++ b/changelog.d/fixes/11149-opencode-go-flat-rate.md @@ -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 diff --git a/src/lib/usage/flatRateProviders.ts b/src/lib/usage/flatRateProviders.ts index 8d3eec2c5d..3454b9b391 100644 --- a/src/lib/usage/flatRateProviders.ts +++ b/src/lib/usage/flatRateProviders.ts @@ -46,6 +46,11 @@ const FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS: ReadonlySet = 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", ]); /** diff --git a/tests/unit/flat-rate-cost-5552.test.ts b/tests/unit/flat-rate-cost-5552.test.ts index 2df378ee3e..61ad9847b1 100644 --- a/tests/unit/flat-rate-cost-5552.test.ts +++ b/tests/unit/flat-rate-cost-5552.test.ts @@ -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 }),