Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixes/11149-opencode-go-flat-rate.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/lib/usage/flatRateProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]);

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/flat-rate-cost-5552.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down Expand Up @@ -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 }),
Expand Down
Loading