Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(usage): price GLM-5.3, Kimi K3.1 Pro, Gemini 4 Carbon, and Antigravity Claude effort ids (#10445)

AstralSolipsism356b92fdbb10
diff --git a/packages/views/runtimes/components/usage-section.test.tsx b/packages/views/runtimes/components/usage-section.test.tsx
index dc19ee74da..2cc82a6686 100644
--- a/packages/views/runtimes/components/usage-section.test.tsx
+++ b/packages/views/runtimes/components/usage-section.test.tsx
@@ -403,3 +403,31 @@ describe("UsageSection — KPI row layout", () => {
expect(classes).toContain("sm:divide-y-0");
});
});
+
+describe("UsageSection — cost-by-model label truncation", () => {
+ it("renders model keys as block elements so long provider-qualified ids truncate before the spend bar", () => {
+ usageOverride.rows = [
+ {
+ runtime_id: "r-1",
+ date: new Date().toISOString().slice(0, 10),
+ provider: "antigravity",
+ model: "claude-opus-5-5-high",
+ input_tokens: 1_000,
+ output_tokens: 500,
+ cache_read_tokens: 0,
+ cache_write_tokens: 0,
+ },
+ ];
+
+ render(<UsageSection runtime={RUNTIME} />, { wrapper: Wrapper });
+ fireEvent.click(screen.getByRole("button", { name: "By model" }));
+
+ const label = screen.getByText("antigravity/claude-opus-5-5-high");
+ // `truncate` (`overflow: hidden; text-overflow: ellipsis`) is inert on an
+ // inline `<span>` inside the non-flex `div.min-w-0` cell, letting long
+ // provider-qualified keys bleed beneath the `relative` spend bar next to them.
+ expect(label.className.split(/\s+/)).toEqual(
+ expect.arrayContaining(["block", "truncate"]),
+ );
+ });
+});
diff --git a/packages/views/runtimes/components/usage-section.tsx b/packages/views/runtimes/components/usage-section.tsx
index 054d7ffff0..df84fcee75 100644
--- a/packages/views/runtimes/components/usage-section.tsx
+++ b/packages/views/runtimes/components/usage-section.tsx
@@ -645,7 +645,7 @@ function CostByBlock({
<CostByList
rows={byModel}
renderKey={(key) => (
- <span className="truncate font-mono text-caption text-foreground">
+ <span className="block truncate font-mono text-caption text-foreground">
{key}
</span>
)}
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.ts
index 64d0002b86..ea94e924e9 100644
--- a/packages/views/runtimes/utils.test.ts
+++ b/packages/views/runtimes/utils.test.ts
@@ -425,6 +425,7 @@ describe("estimateCost", () => {
it("prices published Gemini token SKUs at standard rates in every bucket", () => {
const cases = [
{ model: "gemini-4-argon", input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2 },
+ { model: "gemini-4-carbon", input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2 },
{ model: "gemini-3.8-flash", input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
{ model: "gemini-3.7-flash", input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
{ model: "gemini-3.6-flash", input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
@@ -474,6 +475,7 @@ describe("estimateCost", () => {
["Gemini 3.5 Flash-Lite", "gemini-3.5-flash-lite", 0.3],
["Gemini 3.1 Pro", "gemini-3.1-pro", 2],
["Gemini 4 Argon", "gemini-4-argon", 2],
+ ["Gemini 4 Carbon", "gemini-4-carbon", 2],
] as const) {
for (const model of [label, `${label} (High)`, `google/${label} (Low)`,
`${id}-minimal`, `antigravity:${id}-high`, `custom:google/${id}-low[1m]`]) {
@@ -483,6 +485,54 @@ describe("estimateCost", () => {
}
});
+ it("resolves Antigravity Claude effort suffixes and display labels at the base tier", () => {
+ // Antigravity appends the reasoning effort to Claude ids
+ // (`claude-opus-5-5-high`) or reports the display label. Effort is a
+ // reasoning dial, not a different SKU, so both price at the base model's
+ // tier — but only under the antigravity provider (the scoping stays
+ // pinned by "keeps Cursor variant stripping scoped to Cursor rows"),
+ // mirroring priceForAntigravityModel in server/internal/metrics/pricing.go.
+ const cost = (model: string) =>
+ estimateCost({
+ ...zeroUsage, provider: "antigravity", model,
+ input_tokens: 1_000_000, output_tokens: 1_000_000,
+ cache_read_tokens: 1_000_000, cache_write_tokens: 1_000_000,
+ });
+ const opus55 = 4 + 20 + 0.2 + 5;
+ for (const [model, want] of [
+ ["claude-opus-5-5-high", opus55],
+ ["claude-opus-5-5-medium", opus55],
+ ["claude-sonnet-5-5-low", 2 + 10 + 0.1 + 2.5],
+ ["claude-haiku-5-5-minimal", 0.1 + 0.5 + 0.01 + 0.125],
+ ["claude-opus-5-5-high[1m]", opus55],
+ ["claude-opus-5.5-high", opus55],
+ ["Claude-Opus-5.5-High", opus55],
+ ["antigravity:claude-opus-5-5-high", opus55],
+ ["Claude Opus 5.5 (High)", opus55],
+ ["Claude Opus 5.5", opus55],
+ ] as const) {
+ expect(isModelPriced(model, "antigravity"), model).toBe(true);
+ expect(cost(model), model).toBeCloseTo(want, 5);
+ }
+ expect(collectUnmappedModels([
+ { ...zeroUsage, provider: "antigravity", model: "claude-opus-5-5-high", input_tokens: 1 },
+ { ...zeroUsage, provider: "antigravity", model: "Claude Sonnet 5.5 (Medium)", input_tokens: 1 },
+ ])).toEqual([]);
+ // Only the four effort levels Antigravity supports are stripped, the
+ // version is a major or major.minor number, and one context tag at most;
+ // everything else stays unmapped.
+ for (const model of [
+ "claude-opus-5-5-fast", "claude-opus-5-5-max", "claude-opus-5-5-xhigh",
+ "claude-opus-5-5-thinking", "claude-opus-5-5-preview",
+ "claude-opus-5-5-99-high", "claude-opus-5-5-20261001-high",
+ "claude-opus-5-5-high-latest", "/claude-opus-5-5-high",
+ "claude-opus-5-5[]", "claude-opus-5-5-high[1m][2m]",
+ ]) {
+ expect(isModelPriced(model, "antigravity"), model).toBe(false);
+ expect(cost(model), model).toBe(0);
+ }
+ });
+
it("does not guess Gemini variant or multimodal generation prices", () => {
for (const model of [
"gemini-3.8-flash-lite",
@@ -510,6 +560,8 @@ describe("estimateCost", () => {
"gemini-omni-flash-preview",
"gemini-embedding-2",
"gemini-4-argon-fast",
+ "gemini-4-carbon-fast",
+ "gemini-4-carbon[1m][2m]",
"gemini-4-argon[1m][2m]",
]) {
expect(isModelPriced(model, "antigravity"), model).toBe(false);
@@ -1014,6 +1066,78 @@ describe("estimateCost", () => {
).toBe(0);
});
+ it("prices GLM-5.3 and its paid Flash tier at the official z.ai rates", () => {
+ // docs.z.ai/guides/overview/pricing (2026-11-11): GLM-5.3 $1.4 / $4.4
+ // with $0.26 cached input; GLM-5.3-Flash is the PAID $0.15 / $0.50 tier,
+ // unlike the free 4.x flash tiers above.
+ for (const c of [
+ { model: "glm-5.3", input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 1.4 },
+ { model: "glm-5.3-flash", input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0.15 },
+ ]) {
+ for (const model of [c.model, `zhipuai/${c.model}`]) {
+ const breakdown = estimateCostBreakdown({
+ ...zeroUsage, model,
+ input_tokens: 1_000_000, output_tokens: 1_000_000,
+ cache_read_tokens: 1_000_000, cache_write_tokens: 1_000_000,
+ });
+ expect(breakdown.input, model).toBeCloseTo(c.input, 5);
+ expect(breakdown.output, model).toBeCloseTo(c.output, 5);
+ expect(breakdown.cacheRead, model).toBeCloseTo(c.cacheRead, 5);
+ expect(breakdown.cacheWrite, model).toBeCloseTo(c.cacheWrite, 5);
+ }
+ }
+ // A Hermes custom provider carries a `custom:` routing prefix.
+ expect(collectUnmappedModels([
+ { ...zeroUsage, model: "glm-5.3", input_tokens: 1 },
+ { ...zeroUsage, provider: "hermes", model: "custom:glm-5.3", input_tokens: 1 },
+ { ...zeroUsage, provider: "claude", model: "glm-5.3-flash", input_tokens: 1 },
+ ])).toEqual([]);
+ // Unknown suffixed variants stay unmapped, matching the anchored
+ // backend rules in server/internal/metrics/pricing.go.
+ for (const model of ["glm-5.3-flashx", "glm-5.3-fast", "glm-5.3-extra"]) {
+ expect(isModelPriced(model), model).toBe(false);
+ }
+ });
+
+ it("prices Kimi K3.1 Pro under its vendor and provider-qualified keys", () => {
+ // platform.kimi.ai/docs/pricing/chat (2026-11-11): $2 / $10 / $0.20
+ // cached input, no separate cache write. `k3.1-pro` is a generic id, so
+ // it prices only under the provider-qualified `kimi/k3.1-pro` key — a
+ // bare `k3.1-pro` from an unknown provider stays unmapped like
+ // `cursor/auto`.
+ const k311 = 2 + 10 + 0.2 + 2;
+ for (const [model, provider] of [
+ ["kimi-code/k3.1-pro", "kimi"],
+ ["kimi-k3.1-pro", undefined],
+ ["kimi-k3.1-pro", "kimi"],
+ ] as const) {
+ expect(isModelPriced(model, provider), `${provider}/${model}`).toBe(true);
+ expect(
+ estimateCost({
+ ...zeroUsage, provider, model,
+ input_tokens: 1_000_000, output_tokens: 1_000_000,
+ cache_read_tokens: 1_000_000, cache_write_tokens: 1_000_000,
+ }),
+ `${provider}/${model}`,
+ ).toBeCloseTo(k311, 5);
+ }
+ // The subscription coding-route alias, the CodeBuddy SKU, the
+ // double-price highspeed variant, and the bare id under an unknown or
+ // absent provider all stay unmapped.
+ for (const [model, provider] of [
+ ["kimi-for-coding", "kimi"],
+ ["kimi-code/kimi-for-coding", "kimi"],
+ ["kimi-k3-1", undefined],
+ ["kimi-k3.1-pro-highspeed", undefined],
+ ["kimi-code/k3.1-pro-highspeed", "kimi"],
+ ["k3.1-pro-highspeed", "kimi"],
+ ["k3.1-pro", "acme"],
+ ["k3.1-pro", undefined],
+ ] as const) {
+ expect(isModelPriced(model, provider), `${provider ?? "no-provider"}/${model}`).toBe(false);
+ }
+ });
+
it("prices grok-4.5 at xAI's short-context $2.00 / $6.00 tier", () => {
// 1M input × $2.00 + 1M output × $6.00 + 1M cached-read × $0.30.
// Short context on purpose: the long-context (≥200K prompt) tier is 2x,
diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.ts
index 2aba4d0a1d..7f8c29e904 100644
--- a/packages/views/runtimes/utils.ts
+++ b/packages/views/runtimes/utils.ts
@@ -311,6 +311,8 @@ const MODEL_PRICING: Record<
// Image, Omni and Embedding SKUs stay unmapped because aggregate tokens
// cannot distinguish their rates. Mirror server/internal/metrics/pricing.go. --
"gemini-4-argon": { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2 },
+ // Gemini 4 Carbon shares Argon's intro rate through 2026-11-30 (checked 2026-11-11).
+ "gemini-4-carbon": { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2 },
"gemini-3.8-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
"gemini-3.7-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
"gemini-3.6-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 },
@@ -378,10 +380,24 @@ const MODEL_PRICING: Record<
// Kimi Code CLI reports the same model as `kimi-code/k3`; provider-qualified
// because `k3` is a generic id (see the provider-qualified keys note above).
"kimi/k3": { input: 3.0, output: 15.0, cacheRead: 0.30, cacheWrite: 3.0 },
+ // Kimi K3.1 Pro (platform.kimi.ai/docs/pricing/chat via models.dev
+ // providers/moonshotai/models/kimi-k3.1-pro.toml, 2026-11-11); default 5m
+ // cache write is 1x input, like kimi-k3. `k3.1-pro` is generic, so it prices
+ // only under the provider-qualified `kimi/k3.1-pro` key (also covering
+ // Kimi Code's `kimi-code/k3.1-pro`); the highspeed SKU and CodeBuddy's
+ // `kimi-k3-1` stay unmapped.
+ "kimi-k3.1-pro": { input: 2.0, output: 10.0, cacheRead: 0.20, cacheWrite: 2.0 },
+ "kimi/k3.1-pro": { input: 2.0, output: 10.0, cacheRead: 0.20, cacheWrite: 2.0 },
+ // `kimi-for-coding` is a Kimi Code subscription route alias, not an API
+ // SKU with a published rate, so it stays unmapped.
// -- Zhipu z.ai (docs.z.ai/guides/overview/pricing). Free flash tiers
// are priced at 0 so they resolve cleanly instead of falling through
// to the "unmapped" diagnostic. --
+ // GLM-5.3 and GLM-5.3-Flash (2026-11-11); the 5.3 Flash tier is paid,
+ // unlike the free 4.x flashes below.
+ "glm-5.3": { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 1.4 },
+ "glm-5.3-flash": { input: 0.15, output: 0.5, cacheRead: 0.03, cacheWrite: 0.15 },
"glm-5.1": { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 1.4 },
"glm-5": { input: 1.0, output: 3.2, cacheRead: 0.2, cacheWrite: 1.0 },
"glm-5-turbo": { input: 1.2, output: 4.0, cacheRead: 0.24, cacheWrite: 1.2 },
@@ -630,6 +646,7 @@ function pricingCandidates(model: string, provider?: string): string[] {
const p = normalizeProvider(provider);
if (!p) return base;
if (p === "cursor") return cursorPricingCandidates(model, base);
+ if (p === "antigravity") return antigravityPricingCandidates(model, base, p);
return [...base.map((c) => qualify(p, c)), ...base];
}
@@ -667,6 +684,31 @@ function cursorPricingCandidates(model: string, canonical: string[]): string[] {
return [...new Set([...qualified, `cursor/${base}`, base, ...canonical])];
}
+// Antigravity labels Claude models with the reasoning effort, as a slug
+// suffix (`claude-opus-5-5-high`) or a display label (`Claude Opus 5.5
+// (High)`); effort selects reasoning, not a SKU, so both price at the base
+// tier like canonGemini, scoped to antigravity — a bare `claude-opus-5-5-high`
+// elsewhere stays unmapped; mirrors priceForAntigravityModel in pricing.go.
+const ANTIGRAVITY_CLAUDE_DISPLAY =
+ /^(?:[a-z][a-z0-9_-]*[/:])*claude (opus|sonnet|haiku|fable) (\d+(?:[.-]\d+)?)(?: \((?:minimal|low|medium|high)\))?$/i;
+const ANTIGRAVITY_CLAUDE_EFFORT =
+ /^(?:[a-z][a-z0-9_-]*[/:])*(claude-(?:opus|sonnet|haiku|fable)-\d+(?:[.-]\d+)?)-(?:minimal|low|medium|high)$/i;
+
+function antigravityClaudeBase(model: string): string | undefined {
+ const id = model.trim().replace(/\[[^\]]+\]$/, "");
+ const display = ANTIGRAVITY_CLAUDE_DISPLAY.exec(id);
+ if (display) return `claude-${display[1]}-${display[2]!.replace(/\./g, "-")}`.toLowerCase();
+ const effort = ANTIGRAVITY_CLAUDE_EFFORT.exec(id);
+ return effort?.[1]?.replace(/\./g, "-").toLowerCase();
+}
+// antigravityPricingCandidates appends the Claude base id (one trailing
+// context tag tolerated), keeping the qualified-first lookup order.
+function antigravityPricingCandidates(model: string, base: string[], provider: string): string[] {
+ const claude = antigravityClaudeBase(model);
+ if (!claude) return [...base.map((c) => qualify(provider, c)), ...base];
+ return [...base.map((c) => qualify(provider, c)), `${provider}/${claude}`, ...base, claude];
+}
+
// The canonical storage/diagnostic key for a (model, provider) pair: the
// provider-qualified form when a provider is known, else the bare model.
// `collectUnmappedModels` returns these, and the custom-pricing dialog keys
@@ -772,9 +814,9 @@ function canonicalCandidates(model: string): string[] {
// Antigravity's display labels and effort-suffixed IDs refer to the same
// Gemini SKU. Match only recognized shapes; never strip arbitrary variants.
const canonGemini = (s: string) => {
- const display = /^gemini (\d+(?:\.\d+)?) (flash(?:-lite)?|pro|argon)(?: \((?:minimal|low|medium|high)\))?$/i.exec(s);
+ const display = /^gemini (\d+(?:\.\d+)?) (flash(?:-lite)?|pro|argon|carbon)(?: \((?:minimal|low|medium|high)\))?$/i.exec(s);
if (display) return `gemini-${display[1]}-${display[2]}`.toLowerCase();
- const slug = /^(gemini-\d+(?:\.\d+)?-(?:flash(?:-lite)?|pro|argon))(?:-(?:minimal|low|medium|high))?$/i.exec(s);
+ const slug = /^(gemini-\d+(?:\.\d+)?-(?:flash(?:-lite)?|pro|argon|carbon))(?:-(?:minimal|low|medium|high))?$/i.exec(s);
return slug ? slug[1]!.toLowerCase() : s;
};
diff --git a/server/internal/metrics/cursor_pricing.go b/server/internal/metrics/cursor_pricing.go
index b97376e53a..50245db5b0 100644
--- a/server/internal/metrics/cursor_pricing.go
+++ b/server/internal/metrics/cursor_pricing.go
@@ -160,11 +160,15 @@ func priceForCursorModel(model string) (ModelPrice, bool) {
}
// PriceForRuntimeModel prices usage by the runtime provider that reported it.
-// Cursor bills its catalog at its own rates, so Cursor rows resolve through
-// cursorModelPrices; every other provider uses the vendor table.
+// Cursor rows resolve through cursorModelPrices (its own rates); Antigravity
+// rows go through priceForAntigravityModel (effort-suffixed ids); every other
+// provider uses the vendor table.
func PriceForRuntimeModel(provider, model string) (ModelPrice, bool) {
if strings.EqualFold(strings.TrimSpace(provider), "cursor") {
return priceForCursorModel(model)
}
+ if strings.EqualFold(strings.TrimSpace(provider), "antigravity") {
+ return priceForAntigravityModel(model)
+ }
return PriceForModelAlias(model)
}
diff --git a/server/internal/metrics/cursor_pricing_test.go b/server/internal/metrics/cursor_pricing_test.go
index 9454235303..3cca23ab98 100644
--- a/server/internal/metrics/cursor_pricing_test.go
+++ b/server/internal/metrics/cursor_pricing_test.go
@@ -93,3 +93,63 @@ func TestPriceForRuntimeModelKeepsCursorParsingScopedToCursor(t *testing.T) {
t.Errorf("PriceForRuntimeModel(codex, gpt-5.4) = %+v, %v; want %+v", got, ok, want)
}
}
+
+// TestPriceForRuntimeModelAntigravityClaudeEffort pins the Antigravity-scoped
+// Claude effort fallback: agy reports Claude models with a reasoning-effort
+// suffix or a display label (see readAntigravitySelectedModel in
+// server/pkg/agent/antigravity.go); effort selects reasoning, not a SKU, so
+// the id prices at the base Claude tier. Only the four levels Antigravity
+// supports are stripped, the version is a major or major.minor number, and
+// only the antigravity provider gets the rewrite — the non-Antigravity rows
+// stay pinned unmapped by
+// TestPriceForRuntimeModelKeepsCursorParsingScopedToCursor. Mirrors the
+// antigravity branch of pricingCandidates in
+// packages/views/runtimes/utils.ts.
+func TestPriceForRuntimeModelAntigravityClaudeEffort(t *testing.T) {
+ for _, tc := range []struct {
+ model string
+ key string
+ }{
+ {"claude-opus-5-5-high", "anthropic:claude-opus-5-5"},
+ {"claude-opus-5-5-medium", "anthropic:claude-opus-5-5"},
+ {"claude-sonnet-5-5-low", "anthropic:claude-sonnet-5-5"},
+ {"claude-haiku-5-5-minimal", "anthropic:claude-haiku-5-5"},
+ {"claude-opus-5-5-high[1m]", "anthropic:claude-opus-5-5"},
+ {"claude-opus-5.5-high", "anthropic:claude-opus-5-5"},
+ {"Claude-Opus-5.5-High", "anthropic:claude-opus-5-5"},
+ {"antigravity:claude-opus-5-5-high", "anthropic:claude-opus-5-5"},
+ {"Claude Opus 5.5 (High)", "anthropic:claude-opus-5-5"},
+ {"Claude Opus 5.5", "anthropic:claude-opus-5-5"},
+ {"gemini-4-carbon-high", "google:gemini-4-carbon"},
+ } {
+ want := modelPrices[tc.key]
+ got, ok := PriceForRuntimeModel("antigravity", tc.model)
+ if !ok || got != want {
+ t.Errorf("PriceForRuntimeModel(antigravity, %q) = %+v, %v; want %+v", tc.model, got, ok, want)
+ }
+ }
+ for _, model := range []string{
+ "claude-opus-5-5-fast",
+ "claude-opus-5-5-max",
+ "claude-opus-5-5-xhigh",
+ "claude-opus-5-5-thinking",
+ "claude-opus-5-5-preview",
+ "claude-opus-5-5-99-high",
+ "claude-opus-5-5-20261001-high",
+ "claude-opus-5-5-high-latest",
+ "/claude-opus-5-5-high",
+ "claude-opus-5-5[]",
+ "claude-opus-5-5-high[1m][2m]",
+ "Claude Opus 5.5 (Turbo)",
+ } {
+ if got, ok := PriceForRuntimeModel("antigravity", model); ok {
+ t.Errorf("PriceForRuntimeModel(antigravity, %q) = %+v; want unmapped", model, got)
+ }
+ }
+ // The Claude effort fallback must not leak beyond the antigravity
+ // provider; provider="claude" is pinned by
+ // TestPriceForRuntimeModelKeepsCursorParsingScopedToCursor.
+ if got, ok := PriceForRuntimeModel("", "claude-opus-5-5-high"); ok {
+ t.Errorf("PriceForRuntimeModel(\"\", claude-opus-5-5-high) = %+v; want unmapped", got)
+ }
+}
diff --git a/server/internal/metrics/gemini_pricing_test.go b/server/internal/metrics/gemini_pricing_test.go
index 8696380f8b..6271390048 100644
--- a/server/internal/metrics/gemini_pricing_test.go
+++ b/server/internal/metrics/gemini_pricing_test.go
@@ -8,6 +8,7 @@ func TestPriceForModelAliasGemini(t *testing.T) {
price ModelPrice
}{
{"gemini-4-argon", ModelPrice{Provider: "google", Model: "gemini-4-argon", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2, OutputPerM: 10}},
+ {"gemini-4-carbon", ModelPrice{Provider: "google", Model: "gemini-4-carbon", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2, OutputPerM: 10}},
{"gemini-3.8-flash", ModelPrice{Provider: "google", Model: "gemini-3.8-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75}},
{"gemini-3.7-flash", ModelPrice{Provider: "google", Model: "gemini-3.7-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75}},
{"gemini-3.6-flash", ModelPrice{Provider: "google", Model: "gemini-3.6-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75}},
@@ -48,6 +49,7 @@ func TestPriceForModelAliasGemini(t *testing.T) {
{"Gemini 3.5 Flash-Lite", "gemini-3.5-flash-lite"},
{"Gemini 3.1 Pro", "gemini-3.1-pro"},
{"Gemini 4 Argon", "gemini-4-argon"},
+ {"Gemini 4 Carbon", "gemini-4-carbon"},
} {
want, ok := PriceForModelAlias(tc.id)
if !ok {
@@ -86,6 +88,8 @@ func TestPriceForModelAliasGemini(t *testing.T) {
"gemini-embedding-2",
"gemini-4-argon-fast",
"gemini-4-argon[1m][2m]",
+ "gemini-4-carbon-fast",
+ "gemini-4-carbon[1m][2m]",
} {
if got, ok := PriceForModelAlias(alias); ok {
t.Errorf("unknown or multimodal alias %q borrowed a rate: %+v", alias, got)
diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.go
index 8173e0e12e..a007686dcc 100644
--- a/server/internal/metrics/pricing.go
+++ b/server/internal/metrics/pricing.go
@@ -94,6 +94,7 @@ var modelPrices = map[string]ModelPrice{
// Mixed-modality Live/Image/Omni/Embedding, grounding and hourly cache
// storage cannot be inferred from these token totals.
"google:gemini-4-argon": {Provider: "google", Model: "gemini-4-argon", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2, OutputPerM: 10},
+ "google:gemini-4-carbon": {Provider: "google", Model: "gemini-4-carbon", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2, OutputPerM: 10}, // shares Argon's intro rate through 2026-11-30 (checked 2026-11-11)
"google:gemini-3.8-flash": {Provider: "google", Model: "gemini-3.8-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75},
"google:gemini-3.7-flash": {Provider: "google", Model: "gemini-3.7-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75},
"google:gemini-3.6-flash": {Provider: "google", Model: "gemini-3.6-flash", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 3.75},
@@ -155,6 +156,13 @@ var modelPrices = map[string]ModelPrice{
// providers/moonshotai/models/kimi-k3.toml). Moonshot bills no separate
// cache write, so CacheWritePerM mirrors Input.
"moonshotai:kimi-k3": {Provider: "moonshotai", Model: "kimi-k3", InputPerM: 3.0, CacheReadPerM: 0.30, CacheWritePerM: 3.0, OutputPerM: 15.0},
+ // Kimi K3.1 Pro (platform.kimi.ai/docs/pricing/chat via models.dev
+ // providers/moonshotai/models/kimi-k3.1-pro.toml, 2026-11-11); default 5m
+ // cache write is 1x Input, like kimi-k3.
+ "moonshotai:kimi-k3.1-pro": {Provider: "moonshotai", Model: "kimi-k3.1-pro", InputPerM: 2.0, CacheReadPerM: 0.20, CacheWritePerM: 2.0, OutputPerM: 10.0},
+ // GLM-5.3 / GLM-5.3-Flash (docs.z.ai/guides/overview/pricing, 2026-11-11); the 5.3 Flash tier is paid.
+ "zai:glm-5.3": {Provider: "zai", Model: "glm-5.3", InputPerM: 1.4, CacheReadPerM: 0.26, CacheWritePerM: 1.4, OutputPerM: 4.4},
+ "zai:glm-5.3-flash": {Provider: "zai", Model: "glm-5.3-flash", InputPerM: 0.15, CacheReadPerM: 0.03, CacheWritePerM: 0.15, OutputPerM: 0.5},
// Volcengine Ark (ark.cn-beijing.volces.com). `ark-code-latest` is a
// rolling alias whose target can be switched in the Volcengine console
// (across model families), so it is not a stable model identity; the
@@ -248,6 +256,7 @@ var modelAliasRules = []struct {
// Each Gemini SKU is exact: an image/audio/preview variant must never
// inherit the nearest text model rate. Known efforts normalize below.
{regexp.MustCompile(`(^|/|:)gemini-4-argon$`), "google:gemini-4-argon"},
+ {regexp.MustCompile(`(^|/|:)gemini-4-carbon$`), "google:gemini-4-carbon"},
{regexp.MustCompile(`(^|/|:)gemini-3\.8-flash$`), "google:gemini-3.8-flash"},
{regexp.MustCompile(`(^|/|:)gemini-3\.7-flash$`), "google:gemini-3.7-flash"},
{regexp.MustCompile(`(^|/|:)gemini-3\.6-flash$`), "google:gemini-3.6-flash"},
@@ -299,6 +308,13 @@ var modelAliasRules = []struct {
// unmapped; `kimi-code/k3` (Kimi Code CLI) resolves via the `/k3$` form.
{regexp.MustCompile(`(^|/|:)kimi-k3$`), "moonshotai:kimi-k3"},
{regexp.MustCompile(`(^|/|:)k3$`), "moonshotai:kimi-k3"},
+ // Kimi K3.1 Pro. Anchored so CodeBuddy's `kimi-k3-1` and the highspeed
+ // SKU stay unmapped; `kimi-code/k3.1-pro` resolves via the `/k3.1-pro$` form.
+ {regexp.MustCompile(`(^|/|:)kimi-k3\.1-pro$`), "moonshotai:kimi-k3.1-pro"},
+ {regexp.MustCompile(`(^|/|:)k3\.1-pro$`), "moonshotai:kimi-k3.1-pro"},
+ // Zhipu GLM-5.3. Anchored so unknown suffixed variants stay unmapped.
+ {regexp.MustCompile(`(^|/|:)glm-5\.3$`), "zai:glm-5.3"},
+ {regexp.MustCompile(`(^|/|:)glm-5\.3-flash$`), "zai:glm-5.3-flash"},
// Volcengine Ark `ark-code-latest` is deliberately absent: it is a
// console-switchable rolling alias across model families, not a stable
// model identity, so it stays unmapped.
@@ -315,8 +331,17 @@ var contextTagRe = regexp.MustCompile(`\[[^\]]+\]$`)
// Antigravity reports a display label or an effort-suffixed model ID. Effort
// selects reasoning, not a different SKU. Only strip known effort spellings;
// unknown variants must remain unpriced instead of borrowing a family's rate.
-var geminiDisplayNameRe = regexp.MustCompile(`(^|/|:)gemini ([0-9]+(?:\.[0-9]+)?) (flash(?:-lite)?|pro|argon)(?: \((?:minimal|low|medium|high)\))?$`)
-var geminiEffortSuffixRe = regexp.MustCompile(`((?:^|/|:)gemini-[0-9]+(?:\.[0-9]+)?-(?:flash(?:-lite)?|pro|argon))-(?:minimal|low|medium|high)$`)
+var geminiDisplayNameRe = regexp.MustCompile(`(^|/|:)gemini ([0-9]+(?:\.[0-9]+)?) (flash(?:-lite)?|pro|argon|carbon)(?: \((?:minimal|low|medium|high)\))?$`)
+var geminiEffortSuffixRe = regexp.MustCompile(`((?:^|/|:)gemini-[0-9]+(?:\.[0-9]+)?-(?:flash(?:-lite)?|pro|argon|carbon))-(?:minimal|low|medium|high)$`)
+
+// Antigravity also labels Claude models with the reasoning effort, as a slug
+// suffix (`claude-opus-5-5-high`) or a display label (`Claude Opus 5.5
+// (High)`); effort selects reasoning, not a different SKU. Scoped to the
+// Antigravity runtime because Cursor ids carry the same suffixes at
+// Cursor-specific rates and a bare `claude-opus-5-5-high` elsewhere stays
+// unmapped. Mirrors pricingCandidates in packages/views/runtimes/utils.ts.
+var antigravityClaudeDisplayRe = regexp.MustCompile(`^(?:[a-z][a-z0-9_-]*[/:])*claude (opus|sonnet|haiku|fable) ([0-9]+(?:[.-][0-9]+)?)(?: \((?:minimal|low|medium|high)\))?$`)
+var antigravityClaudeEffortRe = regexp.MustCompile(`^(?:[a-z][a-z0-9_-]*[/:])*(claude-(?:opus|sonnet|haiku|fable)-[0-9]+(?:[.-][0-9]+)?)-(?:minimal|low|medium|high)$`)
func matchModelAlias(model string) (ModelPrice, bool) {
model = geminiDisplayNameRe.ReplaceAllString(model, "${1}gemini-${2}-${3}")
@@ -382,6 +407,23 @@ func PriceForModelAlias(model string) (ModelPrice, bool) {
return ModelPrice{}, false
}
+// priceForAntigravityModel prices usage reported by the Antigravity runtime:
+// after the general resolver misses, retry the Claude effort/display forms.
+// One trailing context tag is the same SKU; the `$` anchor rejects a second.
+func priceForAntigravityModel(model string) (ModelPrice, bool) {
+ if price, ok := PriceForModelAlias(model); ok {
+ return price, true
+ }
+ s := contextTagRe.ReplaceAllString(strings.ToLower(strings.TrimSpace(model)), "")
+ if m := antigravityClaudeDisplayRe.FindStringSubmatch(s); m != nil {
+ return PriceForModelAlias("claude-" + m[1] + "-" + strings.ReplaceAll(m[2], ".", "-"))
+ }
+ if m := antigravityClaudeEffortRe.FindStringSubmatch(s); m != nil {
+ return PriceForModelAlias(strings.ReplaceAll(m[1], ".", "-"))
+ }
+ return ModelPrice{}, false
+}
+
func tokenCostUSD(tokens int64, pricePerM float64) float64 {
if tokens <= 0 || pricePerM <= 0 {
return 0
diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.go
index d87bea3529..1790d76675 100644
--- a/server/internal/metrics/pricing_test.go
+++ b/server/internal/metrics/pricing_test.go
@@ -377,6 +377,59 @@ func TestPriceForModelAliasAlibabaMoonshotVolcengine(t *testing.T) {
}
}
+// TestPriceForModelAliasGLM53AndKimiK31Pro pins the newly priced SKUs and the
+// transports that report them: Hermes' `custom:glm-5.3` and opencode's
+// `zhipuai/glm-5.3` (routing prefixes reach the rows through the `(^|/|:)`
+// anchors), Kimi Code's `kimi-code/k3.1-pro`. The distinct CodeBuddy SKU
+// `kimi-k3-1`, the double-price `kimi-k3.1-pro-highspeed` variants and Kimi
+// Code's subscription coding-route alias `kimi-for-coding` (absent from
+// Moonshot's API price sheet, like `ark-code-latest`) stay unmapped rather
+// than borrowing a guessed rate.
+func TestPriceForModelAliasGLM53AndKimiK31Pro(t *testing.T) {
+ glm53 := ModelPrice{Provider: "zai", Model: "glm-5.3", InputPerM: 1.4, CacheReadPerM: 0.26, CacheWritePerM: 1.4, OutputPerM: 4.4}
+ glm53Flash := ModelPrice{Provider: "zai", Model: "glm-5.3-flash", InputPerM: 0.15, CacheReadPerM: 0.03, CacheWritePerM: 0.15, OutputPerM: 0.5}
+ kimiK31 := ModelPrice{Provider: "moonshotai", Model: "kimi-k3.1-pro", InputPerM: 2.0, CacheReadPerM: 0.20, CacheWritePerM: 2.0, OutputPerM: 10.0}
+ cases := []struct {
+ model string
+ want ModelPrice
+ }{
+ {"glm-5.3", glm53},
+ {"custom:glm-5.3", glm53},
+ {"zhipuai/glm-5.3", glm53},
+ {"glm-5.3[1m]", glm53},
+ {"glm-5.3-flash", glm53Flash},
+ {"kimi-k3.1-pro", kimiK31},
+ {"kimi-code/k3.1-pro", kimiK31},
+ {"k3.1-pro", kimiK31},
+ {"kimi-k3.1-pro[1m]", kimiK31},
+ }
+ for _, tc := range cases {
+ got, ok := PriceForModelAlias(tc.model)
+ if !ok {
+ t.Fatalf("PriceForModelAlias(%q) did not resolve", tc.model)
+ }
+ if got != tc.want {
+ t.Fatalf("PriceForModelAlias(%q) = %+v, want %+v", tc.model, got, tc.want)
+ }
+ }
+
+ for _, model := range []string{
+ "kimi-for-coding",
+ "kimi-code/kimi-for-coding",
+ "kimi-k3-1",
+ "kimi-k3.1-pro-highspeed",
+ "kimi-code/k3.1-pro-highspeed",
+ "k3.1-pro-highspeed",
+ "glm-5.3-flashx",
+ "glm-5.3-fast",
+ "glm-5.3-extra",
+ } {
+ if got, ok := PriceForModelAlias(model); ok {
+ t.Fatalf("PriceForModelAlias(%q) unexpectedly resolved to %+v; want unmapped", model, got)
+ }
+ }
+}
+
// TestPriceForModelAliasNoFalseBorrowing guards the anchored rules: a preview
// SKU must not inherit the GA tier, a distinct CodeBuddy SKU must not inherit
// Kimi K3, unknown suffixed variants must stay unmapped, empty bracket tags