Skip to content

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

Go

fix(usage): price Claude Fable 5.2 for Claude Code runs (#11481)

Eric Yum8854e1691692
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.ts
index c5071cda57..c811be3afc 100644
--- a/packages/views/runtimes/utils.test.ts
+++ b/packages/views/runtimes/utils.test.ts
@@ -180,6 +180,22 @@ describe("estimateCost", () => {
expect(cost).toBeCloseTo(10 + 50 + 0.25 + 12.5, 5);
});
+ // Fable 5.2 has its own, cheaper Anthropic row.
+ it.each(["claude-fable-5-2", "claude-fable-5.2", "claude-fable-5-2[1m]"])(
+ "prices Claude %s at its own 8 / 40 tier",
+ (model) => {
+ const cost = estimateCost({
+ ...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(cost).toBeCloseTo(8 + 40 + 0.2 + 10, 5);
+ },
+ );
+
it.each([
{
model: "claude-sonnet-5-5",
@@ -1499,6 +1515,7 @@ describe("isModelPriced", () => {
expect(isModelPriced("claude-sonnet-5")).toBe(true);
expect(isModelPriced("claude-fable-5")).toBe(true);
expect(isModelPriced("claude-fable-5-1")).toBe(true);
+ expect(isModelPriced("claude-fable-5-2")).toBe(true);
expect(isModelPriced("claude-sonnet-4-6")).toBe(true);
expect(isModelPriced("gpt-5-codex")).toBe(true);
expect(isModelPriced("gpt-5-mini")).toBe(true);
diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.ts
index 8751440539..b3fc32f5f5 100644
--- a/packages/views/runtimes/utils.ts
+++ b/packages/views/runtimes/utils.ts
@@ -251,6 +251,8 @@ const MODEL_PRICING: Record<
// prompt sizes, so long requests are underestimated. Mirror the backend
// estimate in server/internal/metrics/pricing.go.
"claude-haiku-5-5": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 },
+ // Fable 5.2 is cheaper than 5 / 5.1: $8 / $40, cache read $0.20, write $10.
+ "claude-fable-5-2": { input: 8, output: 40, cacheRead: 0.20, cacheWrite: 10.00 },
"claude-fable-5-1": { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.50 },
"claude-fable-5": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },
"claude-opus-5-5": { input: 4, output: 20, cacheRead: 0.20, cacheWrite: 5.00 },
diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.go
index 3fac5be27d..4a664bb7d2 100644
--- a/server/internal/metrics/pricing.go
+++ b/server/internal/metrics/pricing.go
@@ -54,7 +54,9 @@ var modelPrices = map[string]ModelPrice{
// Haiku 5.5 uses the <=100K prompt tier, matching the frontend estimate.
// Above 100K (including cache reads/writes), all four rates are 5x higher.
// Usage aggregates lack per-request prompt sizes, so long requests are underestimated.
- "anthropic:claude-haiku-5-5": {Provider: "anthropic", Model: "claude-haiku-5-5", InputPerM: 0.10, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.50},
+ "anthropic:claude-haiku-5-5": {Provider: "anthropic", Model: "claude-haiku-5-5", InputPerM: 0.10, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.50},
+ // Fable 5.2 (anthropic.com/pricing): $8 / $40, cache read $0.20, cache write $10.
+ "anthropic:claude-fable-5-2": {Provider: "anthropic", Model: "claude-fable-5-2", InputPerM: 8.00, CacheReadPerM: 0.20, CacheWritePerM: 10.00, OutputPerM: 40.00},
"anthropic:claude-fable-5-1": {Provider: "anthropic", Model: "claude-fable-5-1", InputPerM: 10.00, CacheReadPerM: 0.25, CacheWritePerM: 12.50, OutputPerM: 50.00},
"anthropic:claude-fable-5": {Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},
"anthropic:claude-opus-5-5": {Provider: "anthropic", Model: "claude-opus-5-5", InputPerM: 4.00, CacheReadPerM: 0.20, CacheWritePerM: 5.00, OutputPerM: 20.00},
@@ -233,6 +235,7 @@ var modelAliasRules = []struct {
// cache reads at 0.025x input ($0.25) instead of the standard 0.1x, so it
// needs its own row, and both rules end at their own version
// (claudeVersionEnd) so neither can swallow the other's ids.
+ {regexp.MustCompile(`claude-fable-5[-.]2` + claudeVersionEnd), "anthropic:claude-fable-5-2"},
{regexp.MustCompile(`claude-fable-5[-.]1` + claudeVersionEnd), "anthropic:claude-fable-5-1"},
{regexp.MustCompile(`claude-fable-5` + claudeVersionEnd), "anthropic:claude-fable-5"},
// Opus 5.5 is cheaper than Opus 5 ($4 / $20) and prices cache reads at
diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.go
index 1790d76675..2a26d534a1 100644
--- a/server/internal/metrics/pricing_test.go
+++ b/server/internal/metrics/pricing_test.go
@@ -549,6 +549,8 @@ func TestPriceForModelAliasAnthropicFable51(t *testing.T) {
// the Fable 5.1 row specifically.
fable51 := ModelPrice{Provider: "anthropic", Model: "claude-fable-5-1", InputPerM: 10, CacheReadPerM: 0.25, CacheWritePerM: 12.5, OutputPerM: 50}
fable5 := ModelPrice{Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10, CacheReadPerM: 1, CacheWritePerM: 12.5, OutputPerM: 50}
+ // Fable 5.2 is its own, cheaper row.
+ fable52 := ModelPrice{Provider: "anthropic", Model: "claude-fable-5-2", InputPerM: 8, CacheReadPerM: 0.2, CacheWritePerM: 10, OutputPerM: 40}
cases := []struct {
model string
want ModelPrice
@@ -575,6 +577,11 @@ func TestPriceForModelAliasAnthropicFable51(t *testing.T) {
{model: "claude-fable-5-1-20260901", want: fable51},
{model: "claude-fable-5-1-latest", want: fable51},
{model: "claude-fable-5-1-20260901[1m]", want: fable51},
+ {model: "claude-fable-5-2", want: fable52},
+ {model: "claude-fable-5.2", want: fable52},
+ {model: "anthropic/claude-fable-5-2", want: fable52},
+ {model: "claude-fable-5-2[1m]", want: fable52},
+ {model: "claude-fable-5-2-20261101", want: fable52},
}
for _, tc := range cases {
@@ -592,10 +599,11 @@ func TestPriceForModelAliasAnthropicFable51(t *testing.T) {
// neighbour's tier. This is the same failure the `-1` suffix had against
// the Fable 5 rule, so guard it on the 5.1 rule as well.
for _, model := range []string{
- "claude-fable-5-2",
- "claude-fable-5.2",
+ "claude-fable-5-3",
+ "claude-fable-5.3",
"claude-fable-5-10",
"claude-fable-5.10",
+ "claude-fable-5-2x",
"claude-fable-5-1x",
} {
if got, ok := PriceForModelAlias(model); ok {