Skip to content

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

Go

MUL-8418: fix(usage): correct Cursor variant and OpenAI GPT-5.6 pricing (#9739)

Jiayuan Zhange8ae72c9dfc1
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.ts
index a4792c8928..88854abf07 100644
--- a/packages/views/runtimes/utils.test.ts
+++ b/packages/views/runtimes/utils.test.ts
@@ -377,7 +377,7 @@ describe("estimateCost", () => {
});
it("prices current Codex models per OpenAI's official cache-aware rates", () => {
- // Official announcement rates. 5.6 is the first OpenAI generation to bill
+ // OpenAI's standard short-context rates. 5.6 is the first OpenAI generation to bill
// cache writes separately: cacheRead generally = 0.1x input (GPT-6.1
// Sol and Terra use 0.05x), cacheWrite = 1.25x
// input. Cover every model x every token category so a wrong cache rate
@@ -390,8 +390,8 @@ describe("estimateCost", () => {
{ model: "gpt-6-sol", input: 2, cacheRead: 0.2, cacheWrite: 2.5, output: 10, total: 14.7 },
{ model: "gpt-6-luna", input: 0.1, cacheRead: 0.01, cacheWrite: 0.125, output: 0.5, total: 0.735 },
{ model: "gpt-5.6-sol", input: 5, cacheRead: 0.5, cacheWrite: 6.25, output: 30, total: 41.75 },
- { model: "gpt-5.6-terra", input: 2.5, cacheRead: 0.25, cacheWrite: 3.125, output: 15, total: 20.875 },
- { model: "gpt-5.6-luna", input: 1, cacheRead: 0.1, cacheWrite: 1.25, output: 6, total: 8.35 },
+ { model: "gpt-5.6-terra", input: 2, cacheRead: 0.2, cacheWrite: 2.5, output: 12, total: 16.7 },
+ { model: "gpt-5.6-luna", input: 0.2, cacheRead: 0.02, cacheWrite: 0.25, output: 1.2, total: 1.67 },
];
for (const c of cases) {
const breakdown = estimateCostBreakdown({
@@ -514,12 +514,14 @@ describe("estimateCost", () => {
}
});
- it("uses the current routed Flash rate for Cursor 3.5 and 3.6 aliases", () => {
- for (const model of ["gemini-3.5-flash-high", "gemini-3.6-flash-high"]) {
- expect(estimateCost({ ...zeroUsage, provider: "cursor", model,
+ it("prices Cursor's 3.5 and 3.6 Flash at Cursor's sheet, not Google's routed rate", () => {
+ const cost = (model: string) =>
+ estimateCost({ ...zeroUsage, provider: "cursor", model,
input_tokens: 1_000_000, output_tokens: 1_000_000, cache_read_tokens: 1_000_000,
- })).toBeCloseTo(0.75 + 3.75 + 0.075, 5);
- }
+ });
+ expect(cost("gemini-3.5-flash")).toBeCloseTo(1.5 + 9 + 0.15, 5);
+ expect(cost("gemini-3.6-flash-high")).toBeCloseTo(1.5 + 7.5 + 0.15, 5);
+ expect(cost("gemini-3.7-flash-high")).toBeCloseTo(0.75 + 3.75 + 0.075, 5);
});
it("resolves current Codex routing prefixes and context tags", () => {
@@ -745,7 +747,7 @@ describe("estimateCost", () => {
// Thinking after the effort level, and the older `claude-4.6-sonnet` naming.
expect(cost("claude-4.6-sonnet-medium-thinking")).toBeCloseTo(3 + 15 + 0.3 + 3.75, 5);
expect(cost("gpt-5.5-extra-high")).toBeCloseTo(5 + 30 + 0.5, 5);
- expect(cost("gpt-5.6-sol-none")).toBeCloseTo(4 + 20 + 0.4 + 5, 5);
+ expect(cost("gpt-5.6-sol-none")).toBeCloseTo(5 + 30 + 0.5 + 6.25, 5);
expect(cost("cursor-grok-4.6-high")).toBeCloseTo(2 + 6 + 0.5, 5);
expect(cost("grok-4.7-medium")).toBeCloseTo(2 + 6 + 0.5, 5);
expect(cost("gemini-4-argon-medium")).toBeCloseTo(2 + 10 + 0.1, 5);
@@ -757,7 +759,7 @@ describe("estimateCost", () => {
);
});
- it("prices Cursor Fast variants only where Cursor publishes a Fast rate", () => {
+ it("prices Cursor Fast variants only where a Fast rate is published", () => {
const cost = (model: string) =>
estimateCost({
...zeroUsage,
@@ -767,17 +769,38 @@ describe("estimateCost", () => {
output_tokens: 1_000_000,
});
- expect(cost("gpt-5.6-sol-medium-fast")).toBeCloseTo(8 + 40, 5);
+ expect(cost("gpt-5.6-sol-medium-fast")).toBeCloseTo(10 + 60, 5);
expect(cost("cursor-grok-4.5-high-fast")).toBeCloseTo(4 + 18, 5);
expect(cost("claude-opus-4-7-thinking-high-fast")).toBeCloseTo(30 + 150, 5);
expect(cost("claude-opus-4-8[effort=high,fast=true]")).toBeCloseTo(10 + 50, 5);
+ // Cursor's sheet doesn't price these Fast variants; the vendor sheet does.
+ expect(cost("claude-opus-5-5-xhigh-fast")).toBeCloseTo(8 + 40, 5);
+ expect(cost("claude-opus-5-5[fast=true]")).toBeCloseTo(8 + 40, 5);
+ expect(cost("claude-opus-5-thinking-high-fast")).toBeCloseTo(10 + 50, 5);
+ expect(cost("gpt-5.5-extra-high-fast")).toBeCloseTo(12.5 + 75, 5);
+ expect(cost("gpt-5.3-codex-xhigh-fast")).toBeCloseTo(3.5 + 28, 5);
+ expect(cost("gpt-5.2-fast")).toBeCloseTo(3.5 + 28, 5);
// No published Fast rate: unmapped, never the cheaper standard rate.
- expect(isModelPriced("claude-opus-5-5-high-fast", "cursor")).toBe(false);
- expect(isModelPriced("gpt-5.5-medium-fast", "cursor")).toBe(false);
- expect(isModelPriced("claude-opus-5-5[fast=true]", "cursor")).toBe(false);
+ expect(isModelPriced("claude-sonnet-5-5-high-fast", "cursor")).toBe(false);
+ expect(isModelPriced("kimi-k3-fast", "cursor")).toBe(false);
+ expect(isModelPriced("claude-sonnet-5[fast=true]", "cursor")).toBe(false);
expect(collectUnmappedModels([
- { ...zeroUsage, provider: "cursor", model: "claude-opus-5-5-high-fast", input_tokens: 1 },
- ])).toEqual(["cursor/claude-opus-5-5-high-fast"]);
+ { ...zeroUsage, provider: "cursor", model: "claude-sonnet-5-5-high-fast", input_tokens: 1 },
+ ])).toEqual(["cursor/claude-sonnet-5-5-high-fast"]);
+ });
+
+ it("prices Cursor catalog ids missing from the base table", () => {
+ const cost = (model: string) =>
+ estimateCost({
+ ...zeroUsage,
+ provider: "cursor",
+ model,
+ input_tokens: 1_000_000,
+ output_tokens: 1_000_000,
+ cache_read_tokens: 1_000_000,
+ });
+ expect(cost("gpt-5.1-high")).toBeCloseTo(1.25 + 10 + 0.125, 5);
+ expect(cost("deepseek-v41-flash-1017-max")).toBeCloseTo(0.3 + 1.2 + 0.006, 5);
});
it("keeps Cursor variant stripping scoped to Cursor rows", () => {
@@ -1964,7 +1987,7 @@ describe("summarizeTaskUsage", () => {
cache_read_tokens: 712_000,
cache_write_tokens: 50_000,
};
- // gpt-5.6-terra: 2.50 / 15 / 0.25 / 3.125 per million.
+ // gpt-5.6-terra: 2 / 12 / 0.20 / 2.50 per million.
const terra = {
provider: "openai",
model: "gpt-5.6-terra",
@@ -1983,10 +2006,10 @@ describe("summarizeTaskUsage", () => {
});
it("prices each model slice at its own rate, not the combined total", () => {
- // Priced separately: 1.9985 (opus) + 0.331375 (terra).
+ // Priced separately: 1.9985 (opus) + 0.2651 (terra).
// Priced as one blob at either rate, the answer would be wrong.
const s = summarizeTaskUsage([opus, terra]);
- expect(s?.cost).toBeCloseTo(1.9985 + 0.331375, 5);
+ expect(s?.cost).toBeCloseTo(1.9985 + 0.2651, 5);
expect(s?.models).toEqual(["claude-opus-5", "gpt-5.6-terra"]);
});
diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.ts
index 3569f8c1b2..b59122397c 100644
--- a/packages/views/runtimes/utils.ts
+++ b/packages/views/runtimes/utils.ts
@@ -187,8 +187,6 @@ export function formatUsd(n: number): string {
// OpenAI historically did the same, but its GPT-5.6+ generation bills cache
// writes at 1.25× input (cache reads generally get the 90% cached-input
// discount; GPT-6.1 Sol and Terra get 95%), so those rows carry a distinct cacheWrite.
-// Codex usage doesn't yet stream cache-write tokens, so that rate isn't
-// exercised today.
//
// The resolver matches exact keys after stripping a trailing date snapshot
// (see `resolvePricing` below). It deliberately does NOT do startsWith
@@ -250,22 +248,22 @@ const MODEL_PRICING: Record<
// -- OpenAI: dotted-minor Codex catalog SKUs. Each generation is priced
// independently — no fallback to `gpt-5`. Entries track
// `server/pkg/agent/models.go` (Codex provider list).
- // gpt-6-astra and gpt-5.6 (sol/terra/luna) use OpenAI's official rates.
- // 5.6+ is the first OpenAI generation to bill cache writes separately:
- // cacheRead generally = 0.1x input, cacheWrite = 1.25x
- // input (see the header note above). Codex usage doesn't yet report
- // cache-write tokens, so cacheWrite isn't exercised today, but the rate
- // is kept correct for when it is.
+ // GPT-6 and GPT-5.6 rows use OpenAI's standard short-context rates
+ // (developers.openai.com/api/docs/pricing, 2026-10-31). GPT-5.6 Sol
+ // keeps its $5 / $30 list rate; the page's temporary promotional rate is
+ // deliberately not used. 5.6+ is the first OpenAI generation to bill
+ // cache writes separately: cacheRead generally = 0.1x input, cacheWrite
+ // = 1.25x input (see the header note above). Mirror
+ // server/internal/metrics/pricing.go.
"gpt-6-astra": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },
- // Standard short-context rates: developers.openai.com/api/docs/models/.
// GPT-6.1 Sol and Terra's cached input is 0.05x input; GPT-6 Sol's is 0.1x.
"gpt-6.1-sol": { input: 2, output: 10, cacheRead: 0.10, cacheWrite: 2.50 },
"gpt-6.1-terra": { input: 1, output: 5, cacheRead: 0.05, cacheWrite: 1.25 },
"gpt-6-sol": { input: 2, output: 10, cacheRead: 0.20, cacheWrite: 2.50 },
"gpt-6-luna": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 },
"gpt-5.6-sol": { input: 5, output: 30, cacheRead: 0.50, cacheWrite: 6.25 },
- "gpt-5.6-terra": { input: 2.50, output: 15, cacheRead: 0.25, cacheWrite: 3.125 },
- "gpt-5.6-luna": { input: 1, output: 6, cacheRead: 0.10, cacheWrite: 1.25 },
+ "gpt-5.6-terra": { input: 2, output: 12, cacheRead: 0.20, cacheWrite: 2.50 },
+ "gpt-5.6-luna": { input: 0.20, output: 1.20, cacheRead: 0.02, cacheWrite: 0.25 },
"gpt-5.5": { input: 5, output: 30, cacheRead: 0.50, cacheWrite: 5 },
"gpt-5.4-mini": { input: 0.75, output: 4.50, cacheRead: 0.075, cacheWrite: 0.75 },
"gpt-5.4": { input: 2.50, output: 15, cacheRead: 0.25, cacheWrite: 2.50 },
@@ -436,6 +434,8 @@ const MODEL_PRICING: Record<
// runtime model or the legacy key `cursor`. Cursor does not publish a
// cache-write rate for these rows; keep it at 0 so reported
// cache_write_tokens don't invent spend from input pricing.
+ // Every `cursor/` row, and `cursorBaseModel` below, is mirrored in
+ // server/internal/metrics/cursor_pricing.go; keep the two in sync.
"cursor/auto": { input: 1.25, output: 6, cacheRead: 0.25, cacheWrite: 0 },
"cursor/composer-2.5-fast": { input: 3, output: 15, cacheRead: 0.5, cacheWrite: 0 },
"cursor/composer-2.5": { input: 0.5, output: 2.5, cacheRead: 0.2, cacheWrite: 0 },
@@ -453,17 +453,25 @@ const MODEL_PRICING: Record<
// -- Third-party models through Cursor (cursor.com/docs/models-and-pricing,
// "Model pricing"). Cursor bills these at API list price, but its sheet
// is the bill, so Cursor rows use it even where it differs from the
- // vendor rows above (GPT-5.6 Sol is on a Cursor promo through
- // 2026-11-21; update the row when it ends). Keys are the Cursor base id
+ // vendor rows above — except temporary promotional rates, which are not
+ // used: GPT-5.6 Sol keeps its $5 / $30 list rate (Fast at 2x) rather
+ // than the sheet's promo price. Keys are the Cursor base id
// left by `cursorBaseModel`, which drops the effort / thinking / fast
// variant parts — effort and thinking don't change per-token rates.
- // A `-fast` row exists only where Cursor publishes the Fast rate; other
- // Fast variants stay unmapped rather than borrowing the standard rate.
- // Where the sheet lists no cache-write rate, cacheWrite is 0 (same as the
- // Composer rows). Long-context surcharges (GPT >272K input) can't be
- // seen in aggregated rows, so those requests are underestimated. --
+ // A `-fast` row exists only where a Fast rate is published: on Cursor's
+ // sheet, or (where Cursor offers a Fast variant its sheet doesn't price)
+ // on the vendor's own sheet, since Cursor bills third-party models at
+ // API list price. Other Fast variants stay unmapped rather than borrowing the
+ // standard rate. Where the sheet lists no cache-write rate, cacheWrite is
+ // 0 (same as the Composer rows). Long-context surcharges (GPT >272K
+ // input) can't be seen in aggregated rows, so those requests are
+ // underestimated. --
"cursor/claude-opus-5-5": { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5 },
+ // Opus 5.5 / Opus 5 Fast: Anthropic's fast-mode rates, with its cache
+ // multipliers applied on top (Opus 5.5 reads at 0.05x input).
+ "cursor/claude-opus-5-5-fast": { input: 8, output: 40, cacheRead: 0.4, cacheWrite: 10 },
"cursor/claude-opus-5": { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
+ "cursor/claude-opus-5-fast": { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 },
"cursor/claude-opus-4-8": { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
// Published as "3x lower per-token pricing than Opus 4.7 fast mode".
"cursor/claude-opus-4-8-fast": { input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5 },
@@ -480,30 +488,43 @@ const MODEL_PRICING: Record<
"cursor/claude-4-sonnet": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
// <=100K prompt tier; see the claude-haiku-5-5 row above.
"cursor/claude-haiku-5-5": { input: 0.1, output: 0.5, cacheRead: 0.01, cacheWrite: 0.125 },
- "cursor/gpt-5.6-sol": { input: 4, output: 20, cacheRead: 0.4, cacheWrite: 5 },
- "cursor/gpt-5.6-sol-fast": { input: 8, output: 40, cacheRead: 0.8, cacheWrite: 10 },
+ "cursor/gpt-5.6-sol": { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
+ "cursor/gpt-5.6-sol-fast": { input: 10, output: 60, cacheRead: 1, cacheWrite: 12.5 },
"cursor/gpt-5.6-terra": { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5 },
"cursor/gpt-5.6-terra-fast": { input: 4, output: 24, cacheRead: 0.4, cacheWrite: 5 },
"cursor/gpt-5.6-luna": { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 },
"cursor/gpt-5.6-luna-fast": { input: 0.4, output: 2.4, cacheRead: 0.04, cacheWrite: 0.5 },
"cursor/gpt-5.5": { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 },
+ // GPT-5.5 / 5.3 Codex / 5.2 Fast: OpenAI's Fast-tier rates, since Cursor's
+ // sheet doesn't price these Fast variants.
+ "cursor/gpt-5.5-fast": { input: 12.5, output: 75, cacheRead: 1.25, cacheWrite: 0 },
"cursor/gpt-5.4": { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 },
"cursor/gpt-5.4-fast": { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 },
"cursor/gpt-5.4-mini": { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 },
"cursor/gpt-5.4-nano": { input: 0.2, output: 1.25, cacheRead: 0.02, cacheWrite: 0 },
"cursor/gpt-5.3-codex": { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 },
+ "cursor/gpt-5.3-codex-fast": { input: 3.5, output: 28, cacheRead: 0.35, cacheWrite: 0 },
"cursor/gpt-5.2": { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 },
+ "cursor/gpt-5.2-fast": { input: 3.5, output: 28, cacheRead: 0.35, cacheWrite: 0 },
+ // GPT-5.1 is in Cursor's catalog but missing from its sheet: OpenAI list price.
+ "cursor/gpt-5.1": { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 },
+ "cursor/gpt-5": { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 },
+ "cursor/gpt-5-fast": { input: 2.5, output: 20, cacheRead: 0.25, cacheWrite: 0 },
"cursor/gpt-5-mini": { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0 },
"cursor/gemini-4-argon": { input: 2, output: 10, cacheRead: 0.1, cacheWrite: 0 },
"cursor/gemini-3.8-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 },
"cursor/gemini-3.7-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 },
- "cursor/gemini-3.6-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 },
- "cursor/gemini-3.5-flash": { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0 },
+ // Cursor bills 3.6 / 3.5 Flash above Google's current (promotional /
+ // rerouted) rate used by the bare rows; Cursor's sheet is the bill here.
+ "cursor/gemini-3.6-flash": { input: 1.5, output: 7.5, cacheRead: 0.15, cacheWrite: 0 },
+ "cursor/gemini-3.5-flash": { input: 1.5, output: 9, cacheRead: 0.15, cacheWrite: 0 },
"cursor/gemini-3.1-pro": { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 0 },
"cursor/gemini-3-flash": { input: 0.5, output: 3, cacheRead: 0.05, cacheWrite: 0 },
"cursor/kimi-k3": { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 },
"cursor/kimi-k2.7-code": { input: 0.95, output: 4, cacheRead: 0.19, cacheWrite: 0 },
"cursor/glm-5.2": { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 0 },
+ // Cursor spells DeepSeek V4.1 Flash 1017 without the dot.
+ "cursor/deepseek-v41-flash-1017": { input: 0.3, output: 1.2, cacheRead: 0.006, cacheWrite: 0 },
"cursor/muse-wonder-1.0": { input: 4, output: 20, cacheRead: 0.2, cacheWrite: 0 },
"cursor/muse-spark-1.3": { input: 1.25, output: 4.25, cacheRead: 0.15, cacheWrite: 0 },
diff --git a/server/internal/metrics/business.go b/server/internal/metrics/business.go
index f027ceb834..f12546ca1f 100644
--- a/server/internal/metrics/business.go
+++ b/server/internal/metrics/business.go
@@ -666,7 +666,7 @@ func (m *BusinessMetrics) RecordLLMUsage(source, runtimeMode, rawProvider, model
}
source = NormalizeTaskSource(source)
runtimeMode = NormalizeRuntimeMode(runtimeMode)
- price, priced := PriceForModelAlias(modelAlias)
+ price, priced := PriceForRuntimeModel(rawProvider, modelAlias)
if !priced {
provider := NormalizeRuntimeProvider(rawProvider)
alias := NormalizeModelAlias(modelAlias)
diff --git a/server/internal/metrics/business_test.go b/server/internal/metrics/business_test.go
index 11672d92b0..9f943e18a0 100644
--- a/server/internal/metrics/business_test.go
+++ b/server/internal/metrics/business_test.go
@@ -123,6 +123,22 @@ func TestBusinessMetricsLLMPricingAndUnpricedTokens(t *testing.T) {
}
}
+func TestBusinessMetricsLLMPricingCursorFastVariant(t *testing.T) {
+ m := NewBusinessMetrics()
+
+ m.RecordLLMUsage("issue", "local", "cursor", "claude-opus-4-7-thinking-high-fast", 1_000_000, 1_000_000, 0, 0, 0)
+
+ if got := testutil.ToFloat64(m.llmCostUSD.WithLabelValues("cursor", "claude-opus-4-7-fast", "input", "local", "issue")); got != 30 {
+ t.Fatalf("cursor fast input cost = %v, want 30", got)
+ }
+ if got := testutil.ToFloat64(m.llmCostUSD.WithLabelValues("cursor", "claude-opus-4-7-fast", "output", "local", "issue")); got != 150 {
+ t.Fatalf("cursor fast output cost = %v, want 150", got)
+ }
+ if got := testutil.ToFloat64(m.llmRequests.WithLabelValues("cursor", "claude-opus-4-7-fast", "local")); got != 1 {
+ t.Fatalf("cursor fast request counter = %v, want 1", got)
+ }
+}
+
func TestBusinessMetricsRegistryExposesAllFamilies(t *testing.T) {
registry := prometheus.NewRegistry()
m := NewBusinessMetrics()
diff --git a/server/internal/metrics/cursor_pricing.go b/server/internal/metrics/cursor_pricing.go
new file mode 100644
index 0000000000..b97376e53a
--- /dev/null
+++ b/server/internal/metrics/cursor_pricing.go
@@ -0,0 +1,170 @@
+package metrics
+
+import (
+ "regexp"
+ "strings"
+)
+
+// cursorModelPrices is what Cursor bills for each model in its catalog
+// (cursor.com/docs/models-and-pricing), keyed by the base id cursorBaseModel
+// leaves. Cursor's sheet is the bill even where it differs from the vendor
+// rows in modelPrices, except that temporary promotional rates are not used:
+// GPT-5.6 Sol keeps its $5 / $30 list rate (Fast at 2x). Where Cursor offers
+// a Fast variant its sheet doesn't price, the `-fast` row carries the vendor's
+// published Fast rate, since Cursor bills third-party models at API list
+// price; other Fast variants stay unmapped rather than borrowing the cheaper
+// standard rate. Where the sheet lists no cache-write rate, CacheWritePerM
+// is 0.
+//
+// Columns are input, output, cache read, cache write — the same order as the
+// `cursor/` rows in packages/views/runtimes/utils.ts, which this table mirrors;
+// keep the two in sync.
+var cursorModelPrices = buildCursorPrices([]struct {
+ model string
+ input, output, cacheRead, cacheWrite float64
+}{
+ {"auto", 1.25, 6, 0.25, 0},
+ {"composer-2.5-fast", 3, 15, 0.5, 0},
+ {"composer-2.5", 0.5, 2.5, 0.2, 0},
+ {"composer-2-fast", 1.5, 7.5, 0.35, 0},
+ {"composer-2", 0.5, 2.5, 0.2, 0},
+ {"composer-1.5", 3.5, 17.5, 0.35, 0},
+ {"composer-1", 1.25, 10, 0.125, 0},
+ {"grok-4.7", 2, 6, 0.5, 0},
+ {"grok-4.7-fast", 4, 12, 1, 0},
+ {"grok-4.6", 2, 6, 0.5, 0},
+ {"grok-4.6-fast", 4, 12, 1, 0},
+ {"grok-4.5", 2, 6, 0.5, 0},
+ {"grok-4.5-fast", 4, 18, 1, 0},
+
+ {"claude-opus-5-5", 4, 20, 0.2, 5},
+ {"claude-opus-5-5-fast", 8, 40, 0.4, 10},
+ {"claude-opus-5", 5, 25, 0.5, 6.25},
+ {"claude-opus-5-fast", 10, 50, 1, 12.5},
+ {"claude-opus-4-8", 5, 25, 0.5, 6.25},
+ {"claude-opus-4-8-fast", 10, 50, 1, 12.5},
+ {"claude-opus-4-7", 5, 25, 0.5, 6.25},
+ {"claude-opus-4-7-fast", 30, 150, 3, 37.5},
+ {"claude-4.6-opus", 5, 25, 0.5, 6.25},
+ {"claude-4.5-opus", 5, 25, 0.5, 6.25},
+ {"claude-fable-5-1", 10, 50, 0.25, 12.5},
+ {"claude-fable-5", 10, 50, 1, 12.5},
+ {"claude-sonnet-5-5", 2, 10, 0.1, 2.5},
+ {"claude-sonnet-5", 2, 10, 0.2, 2.5},
+ {"claude-4.6-sonnet", 3, 15, 0.3, 3.75},
+ {"claude-4.5-sonnet", 3, 15, 0.3, 3.75},
+ {"claude-4-sonnet", 3, 15, 0.3, 3.75},
+ {"claude-haiku-5-5", 0.1, 0.5, 0.01, 0.125},
+ {"gpt-5.6-sol", 5, 30, 0.5, 6.25},
+ {"gpt-5.6-sol-fast", 10, 60, 1, 12.5},
+ {"gpt-5.6-terra", 2, 12, 0.2, 2.5},
+ {"gpt-5.6-terra-fast", 4, 24, 0.4, 5},
+ {"gpt-5.6-luna", 0.2, 1.2, 0.02, 0.25},
+ {"gpt-5.6-luna-fast", 0.4, 2.4, 0.04, 0.5},
+ {"gpt-5.5", 5, 30, 0.5, 0},
+ {"gpt-5.5-fast", 12.5, 75, 1.25, 0},
+ {"gpt-5.4", 2.5, 15, 0.25, 0},
+ {"gpt-5.4-fast", 5, 30, 0.5, 0},
+ {"gpt-5.4-mini", 0.75, 4.5, 0.075, 0},
+ {"gpt-5.4-nano", 0.2, 1.25, 0.02, 0},
+ {"gpt-5.3-codex", 1.75, 14, 0.175, 0},
+ {"gpt-5.3-codex-fast", 3.5, 28, 0.35, 0},
+ {"gpt-5.2", 1.75, 14, 0.175, 0},
+ {"gpt-5.2-fast", 3.5, 28, 0.35, 0},
+ {"gpt-5.1", 1.25, 10, 0.125, 0},
+ {"gpt-5", 1.25, 10, 0.125, 0},
+ {"gpt-5-fast", 2.5, 20, 0.25, 0},
+ {"gpt-5-mini", 0.25, 2, 0.025, 0},
+ {"gemini-4-argon", 2, 10, 0.1, 0},
+ {"gemini-3.8-flash", 0.75, 3.75, 0.075, 0},
+ {"gemini-3.7-flash", 0.75, 3.75, 0.075, 0},
+ {"gemini-3.6-flash", 1.5, 7.5, 0.15, 0},
+ {"gemini-3.5-flash", 1.5, 9, 0.15, 0},
+ {"gemini-3.1-pro", 2, 12, 0.2, 0},
+ {"gemini-3-flash", 0.5, 3, 0.05, 0},
+ {"kimi-k3", 3, 15, 0.3, 0},
+ {"kimi-k2.7-code", 0.95, 4, 0.19, 0},
+ {"glm-5.2", 1.4, 4.4, 0.26, 0},
+ {"deepseek-v41-flash-1017", 0.3, 1.2, 0.006, 0},
+ {"muse-wonder-1.0", 4, 20, 0.2, 0},
+ {"muse-spark-1.3", 1.25, 4.25, 0.15, 0},
+
+ // The daemon reports the literal `cursor` when neither the result event
+ // nor the runtime config names a model; Composer 2.5 Fast is the default.
+ {"cursor", 3, 15, 0.5, 0},
+})
+
+func buildCursorPrices(rows []struct {
+ model string
+ input, output, cacheRead, cacheWrite float64
+}) map[string]ModelPrice {
+ prices := make(map[string]ModelPrice, len(rows))
+ for _, r := range rows {
+ prices[r.model] = ModelPrice{
+ Provider: "cursor",
+ Model: r.model,
+ InputPerM: r.input,
+ OutputPerM: r.output,
+ CacheReadPerM: r.cacheRead,
+ CacheWritePerM: r.cacheWrite,
+ }
+ }
+ return prices
+}
+
+var (
+ cursorParamsRe = regexp.MustCompile(`\[([^\]]*)\]$`)
+ cursorFastParamRe = regexp.MustCompile(`(?:^|,)\s*fast\s*=\s*true\s*(?:,|$)`)
+ cursorVariantSuffixRe = regexp.MustCompile(`-(?:fast|thinking|none|minimal|low|medium|high|xhigh|extra-high|max)$`)
+)
+
+// cursorBaseModel splits a Cursor catalog id into its base model and whether
+// it selects Fast mode. Variant parts come in no fixed order
+// (`claude-opus-4-7-thinking-high-fast`, `claude-4.6-sonnet-medium-thinking`,
+// `cursor-grok-4.6-high`) or as parameters
+// (`claude-opus-4-8[context=1m,effort=high,fast=true]`). Effort and thinking
+// don't change per-token rates; Fast does.
+func cursorBaseModel(model string) (base string, fast bool) {
+ id := strings.ToLower(strings.TrimSpace(model))
+ if m := cursorParamsRe.FindStringSubmatchIndex(id); m != nil {
+ fast = cursorFastParamRe.MatchString(id[m[2]:m[3]])
+ id = id[:m[0]]
+ }
+ for {
+ loc := cursorVariantSuffixRe.FindStringIndex(id)
+ if loc == nil {
+ break
+ }
+ if id[loc[0]:] == "-fast" {
+ fast = true
+ }
+ id = id[:loc[0]]
+ }
+ return strings.TrimPrefix(id, "cursor-"), fast
+}
+
+// priceForCursorModel prices usage reported by the Cursor runtime. A Fast
+// variant resolves only through its own `<base>-fast` row, never the base
+// model's cheaper rate. A standard variant uses Cursor's row for the base
+// model, then the vendor row for the same SKU.
+func priceForCursorModel(model string) (ModelPrice, bool) {
+ base, fast := cursorBaseModel(model)
+ if fast {
+ price, ok := cursorModelPrices[base+"-fast"]
+ return price, ok
+ }
+ if price, ok := cursorModelPrices[base]; ok {
+ return price, true
+ }
+ return PriceForModelAlias(base)
+}
+
+// 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.
+func PriceForRuntimeModel(provider, model string) (ModelPrice, bool) {
+ if strings.EqualFold(strings.TrimSpace(provider), "cursor") {
+ return priceForCursorModel(model)
+ }
+ return PriceForModelAlias(model)
+}
diff --git a/server/internal/metrics/cursor_pricing_test.go b/server/internal/metrics/cursor_pricing_test.go
new file mode 100644
index 0000000000..9454235303
--- /dev/null
+++ b/server/internal/metrics/cursor_pricing_test.go
@@ -0,0 +1,95 @@
+package metrics
+
+import "testing"
+
+func TestPriceForRuntimeModelCursorVariants(t *testing.T) {
+ for _, tc := range []struct {
+ model string
+ want string
+ }{
+ // Effort and thinking parts, in either order, don't change the rate.
+ {"claude-opus-5-5-xhigh", "claude-opus-5-5"},
+ {"claude-opus-5-thinking-max", "claude-opus-5"},
+ {"claude-4.6-sonnet-medium-thinking", "claude-4.6-sonnet"},
+ {"claude-fable-5-1-thinking-high", "claude-fable-5-1"},
+ {"gpt-5.5-extra-high", "gpt-5.5"},
+ {"gpt-5.6-sol-none", "gpt-5.6-sol"},
+ {"gpt-5.3-codex-xhigh", "gpt-5.3-codex"},
+ {"gpt-5.1-high", "gpt-5.1"},
+ {"cursor-grok-4.6-high", "grok-4.6"},
+ {"muse-wonder-1.0-minimal", "muse-wonder-1.0"},
+ {"deepseek-v41-flash-1017-max", "deepseek-v41-flash-1017"},
+ {"claude-opus-4-8[context=1m,effort=high,fast=false]", "claude-opus-4-8"},
+ {"Claude-Opus-5-5-High", "claude-opus-5-5"},
+ {"auto", "auto"},
+ {"composer-2.5", "composer-2.5"},
+ {"cursor", "cursor"},
+ // Fast resolves to its own row, from a suffix or a parameter.
+ {"composer-2.5-fast", "composer-2.5-fast"},
+ {"cursor-grok-4.5-high-fast", "grok-4.5-fast"},
+ {"grok-4.7-xhigh-fast", "grok-4.7-fast"},
+ {"claude-opus-4-7-thinking-high-fast", "claude-opus-4-7-fast"},
+ {"claude-opus-4-8[effort=high,fast=true]", "claude-opus-4-8-fast"},
+ {"claude-opus-5-5-xhigh-fast", "claude-opus-5-5-fast"},
+ {"gpt-5.4-xhigh-fast", "gpt-5.4-fast"},
+ {"gpt-5.5-medium-fast", "gpt-5.5-fast"},
+ } {
+ got, ok := PriceForRuntimeModel("cursor", tc.model)
+ if !ok {
+ t.Errorf("PriceForRuntimeModel(cursor, %q) did not resolve", tc.model)
+ continue
+ }
+ if want := cursorModelPrices[tc.want]; got != want {
+ t.Errorf("PriceForRuntimeModel(cursor, %q) = %+v, want %+v", tc.model, got, want)
+ }
+ }
+}
+
+func TestPriceForRuntimeModelCursorRates(t *testing.T) {
+ for _, tc := range []struct {
+ model string
+ input, output, cacheRead, cacheWrite float64
+ }{
+ {"claude-opus-4-7-high-fast", 30, 150, 3, 37.5},
+ {"claude-opus-5-5-high-fast", 8, 40, 0.4, 10},
+ {"claude-opus-5-high-fast", 10, 50, 1, 12.5},
+ {"gpt-5.5-high-fast", 12.5, 75, 1.25, 0},
+ {"gemini-3.6-flash-high", 1.5, 7.5, 0.15, 0},
+ {"gemini-3.5-flash", 1.5, 9, 0.15, 0},
+ } {
+ got, ok := PriceForRuntimeModel("cursor", tc.model)
+ if !ok {
+ t.Errorf("PriceForRuntimeModel(cursor, %q) did not resolve", tc.model)
+ continue
+ }
+ if got.InputPerM != tc.input || got.OutputPerM != tc.output || got.CacheReadPerM != tc.cacheRead || got.CacheWritePerM != tc.cacheWrite {
+ t.Errorf("PriceForRuntimeModel(cursor, %q) = %+v, want %v/%v/%v/%v", tc.model, got, tc.input, tc.output, tc.cacheRead, tc.cacheWrite)
+ }
+ }
+}
+
+func TestPriceForRuntimeModelCursorFastNeverBorrowsStandardRate(t *testing.T) {
+ for _, model := range []string{
+ "claude-sonnet-5-5-high-fast",
+ "claude-sonnet-5[fast=true]",
+ "kimi-k3-fast",
+ "gemini-4-argon-fast",
+ } {
+ if got, ok := PriceForRuntimeModel("cursor", model); ok {
+ t.Errorf("PriceForRuntimeModel(cursor, %q) = %+v; want unmapped", model, got)
+ }
+ }
+}
+
+func TestPriceForRuntimeModelKeepsCursorParsingScopedToCursor(t *testing.T) {
+ if got, ok := PriceForRuntimeModel("claude", "claude-opus-5-5-high"); ok {
+ t.Errorf("non-Cursor variant id resolved to %+v; want unmapped", got)
+ }
+ if got, ok := PriceForRuntimeModel("claude", "auto"); ok {
+ t.Errorf("non-Cursor `auto` resolved to %+v; want unmapped", got)
+ }
+ got, ok := PriceForRuntimeModel("codex", "gpt-5.4")
+ if want := modelPrices["openai:gpt-5.4"]; !ok || got != want {
+ t.Errorf("PriceForRuntimeModel(codex, gpt-5.4) = %+v, %v; want %+v", got, ok, want)
+ }
+}
diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.go
index be1e24419f..8173e0e12e 100644
--- a/server/internal/metrics/pricing.go
+++ b/server/internal/metrics/pricing.go
@@ -21,14 +21,16 @@ type ModelPrice struct {
}
var modelPrices = map[string]ModelPrice{
- // GPT-5.6 series and GPT-6 Astra (Codex `codex` provider). Official rates
- // from OpenAI's GPT-5.6 announcement (openai.com/index/previewing-gpt-5-6-sol)
- // and Astra's published $10 / $50. For 5.6+ (including Astra) cache read is
- // generally the 90%-off cached-input rate (0.1x input). Cache write is billed
- // at 1.25x the uncached input rate — unlike earlier OpenAI SKUs, which don't
- // bill cache writes separately. Codex app-server v0.147 reports cache-write
- // input separately while including it in the raw input total; the collector
- // normalizes those into mutually exclusive billing buckets.
+ // GPT-5.6 series and GPT-6 (Codex `codex` provider): standard short-context
+ // rates from developers.openai.com/api/docs/pricing (2026-10-31). GPT-5.6
+ // Sol keeps its $5 / $30 list rate; the page's temporary promotional rate is
+ // deliberately not used. For 5.6+ (including Astra) cache read is generally
+ // the 90%-off cached-input rate (0.1x input). Cache write is billed at 1.25x
+ // the uncached input rate. Earlier OpenAI SKUs don't bill cache writes
+ // separately, so their written tokens bill as ordinary input and
+ // CacheWritePerM mirrors InputPerM. Codex app-server v0.147 reports
+ // cache-write input separately while including it in the raw input total;
+ // the collector normalizes those into mutually exclusive billing buckets.
"openai:gpt-6-astra": {Provider: "openai", Model: "gpt-6-astra", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},
// Standard short-context rates from developers.openai.com/api/docs/models/.
// GPT-6.1 Sol and Terra cache at 0.05x input, not GPT-6 Sol's 0.1x.
@@ -37,13 +39,13 @@ var modelPrices = map[string]ModelPrice{
"openai:gpt-6-sol": {Provider: "openai", Model: "gpt-6-sol", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 10.00},
"openai:gpt-6-luna": {Provider: "openai", Model: "gpt-6-luna", InputPerM: 0.10, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.50},
"openai:gpt-5.6-sol": {Provider: "openai", Model: "gpt-5.6-sol", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 30.00},
- "openai:gpt-5.6-terra": {Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2.50, CacheReadPerM: 0.25, CacheWritePerM: 3.125, OutputPerM: 15.00},
- "openai:gpt-5.6-luna": {Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 1.00, CacheReadPerM: 0.10, CacheWritePerM: 1.25, OutputPerM: 6.00},
- "openai:gpt-5.5": {Provider: "openai", Model: "gpt-5.5", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 0.50, OutputPerM: 30.00},
- "openai:gpt-5.4": {Provider: "openai", Model: "gpt-5.4", InputPerM: 2.50, CacheReadPerM: 0.25, CacheWritePerM: 0.25, OutputPerM: 15.00},
- "openai:gpt-5.4-mini": {Provider: "openai", Model: "gpt-5.4-mini", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.075, OutputPerM: 4.50},
- "openai:gpt-5.3-codex": {Provider: "openai", Model: "gpt-5.3-codex", InputPerM: 1.75, CacheReadPerM: 0.175, CacheWritePerM: 0.175, OutputPerM: 14.00},
- "openai:gpt-5.2-codex": {Provider: "openai", Model: "gpt-5.2-codex", InputPerM: 1.75, CacheReadPerM: 0.175, CacheWritePerM: 0.175, OutputPerM: 14.00},
+ "openai:gpt-5.6-terra": {Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 12.00},
+ "openai:gpt-5.6-luna": {Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 0.20, CacheReadPerM: 0.02, CacheWritePerM: 0.25, OutputPerM: 1.20},
+ "openai:gpt-5.5": {Provider: "openai", Model: "gpt-5.5", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 5.00, OutputPerM: 30.00},
+ "openai:gpt-5.4": {Provider: "openai", Model: "gpt-5.4", InputPerM: 2.50, CacheReadPerM: 0.25, CacheWritePerM: 2.50, OutputPerM: 15.00},
+ "openai:gpt-5.4-mini": {Provider: "openai", Model: "gpt-5.4-mini", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 4.50},
+ "openai:gpt-5.3-codex": {Provider: "openai", Model: "gpt-5.3-codex", InputPerM: 1.75, CacheReadPerM: 0.175, CacheWritePerM: 1.75, OutputPerM: 14.00},
+ "openai:gpt-5.2-codex": {Provider: "openai", Model: "gpt-5.2-codex", InputPerM: 1.75, CacheReadPerM: 0.175, CacheWritePerM: 1.75, OutputPerM: 14.00},
// Anthropic's Sonnet 5 launch price is $2 / $10 through 2026-08-31. This
// static table cannot schedule the published post-intro $3 / $15 change yet,
// so keep the intro rate here and update the row when catalog support exists.
diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.go
index fca48ead6e..9cc281ce67 100644
--- a/server/internal/metrics/pricing_test.go
+++ b/server/internal/metrics/pricing_test.go
@@ -59,8 +59,8 @@ func TestPriceForModelAliasAnthropicCurrentGeneration(t *testing.T) {
}
func TestPriceForModelAliasCodexCurrentGeneration(t *testing.T) {
- // Official rates from OpenAI's GPT-5.6 announcement: cache read = 0.1x
- // input (90% cached-input discount), cache write = 1.25x input.
+ // OpenAI's standard short-context rates: cache read = 0.1x input (90%
+ // cached-input discount; 0.05x on GPT-6.1), cache write = 1.25x input.
cases := []struct {
model string
want ModelPrice
@@ -99,11 +99,25 @@ func TestPriceForModelAliasCodexCurrentGeneration(t *testing.T) {
},
{
model: "openai:gpt-5.6-terra",
- want: ModelPrice{Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2.5, CacheReadPerM: 0.25, CacheWritePerM: 3.125, OutputPerM: 15},
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 12},
},
{
model: "openai/gpt-5.6-luna",
- want: ModelPrice{Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 1, CacheReadPerM: 0.1, CacheWritePerM: 1.25, OutputPerM: 6},
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 0.2, CacheReadPerM: 0.02, CacheWritePerM: 0.25, OutputPerM: 1.2},
+ },
+ // Pre-5.6 SKUs don't bill cache writes separately: written tokens are
+ // ordinary input, never the discounted cache-read rate.
+ {
+ model: "gpt-5.5",
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.5", InputPerM: 5, CacheReadPerM: 0.5, CacheWritePerM: 5, OutputPerM: 30},
+ },
+ {
+ model: "gpt-5.4-mini",
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.4-mini", InputPerM: 0.75, CacheReadPerM: 0.075, CacheWritePerM: 0.75, OutputPerM: 4.5},
+ },
+ {
+ model: "gpt-5.3-codex",
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.3-codex", InputPerM: 1.75, CacheReadPerM: 0.175, CacheWritePerM: 1.75, OutputPerM: 14},
},
}
@@ -441,7 +455,7 @@ func TestPriceForModelAliasContextTagStripping(t *testing.T) {
},
{
model: "gpt-5.6-luna[1m]",
- want: ModelPrice{Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 1.00, CacheReadPerM: 0.10, CacheWritePerM: 1.25, OutputPerM: 6.00},
+ want: ModelPrice{Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 0.20, CacheReadPerM: 0.02, CacheWritePerM: 0.25, OutputPerM: 1.20},
},
{
model: "kimi-k3[1m]",