Skip to content

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

Go

BHI-12314: add Claude Sonnet 5 catalog and pricing support (MUL-3910) (#4783)

bhirstmedia170750242b29
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.ts
index 37fae3c472..2205bef141 100644
--- a/packages/views/runtimes/utils.test.ts
+++ b/packages/views/runtimes/utils.test.ts
@@ -141,6 +141,18 @@ describe("estimateCost", () => {
expect(cost).toBeCloseTo(10 + 50 + 1 + 12.5, 5);
});
+ it("prices Claude Sonnet 5 at Anthropic's intro $2 / $10 tier", () => {
+ const cost = estimateCost({
+ ...zeroUsage,
+ model: "claude-sonnet-5",
+ 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(2 + 10 + 0.2 + 2.5, 5);
+ });
+
it("prices the provider-prefixed Anthropic form (anthropic/claude-sonnet-4.6)", () => {
// openclaw / opencode emit `<provider>/<model>`. Same SKU as the
// bare form, must hit the same rate.
@@ -419,6 +431,7 @@ describe("estimateCost", () => {
describe("isModelPriced", () => {
it("recognises both Claude and Codex/GPT families", () => {
+ expect(isModelPriced("claude-sonnet-5")).toBe(true);
expect(isModelPriced("claude-fable-5")).toBe(true);
expect(isModelPriced("claude-sonnet-4-6")).toBe(true);
expect(isModelPriced("gpt-5-codex")).toBe(true);
@@ -432,6 +445,7 @@ describe("isModelPriced", () => {
// while Anthropic's own CLIs use dashes (`claude-opus-4-7`). Both must
// hit the same catalog row, otherwise Copilot-routed usage gets bucketed
// as "unmapped" and the user has to type the price in by hand.
+ expect(isModelPriced("claude-sonnet-5")).toBe(true);
expect(isModelPriced("claude-haiku-4.5")).toBe(true);
expect(isModelPriced("claude-sonnet-4.5")).toBe(true);
expect(isModelPriced("claude-sonnet-4.6")).toBe(true);
@@ -443,6 +457,7 @@ describe("isModelPriced", () => {
it("recognises provider-prefixed Anthropic IDs (openclaw / opencode form)", () => {
// openclaw / opencode emit `<provider>/<model>` in `meta.agentMeta.model`.
// The provider prefix is routing metadata, not part of the SKU.
+ expect(isModelPriced("anthropic/claude-sonnet-5")).toBe(true);
expect(isModelPriced("anthropic/claude-fable-5")).toBe(true);
expect(isModelPriced("anthropic/claude-opus-4.7")).toBe(true);
expect(isModelPriced("anthropic/claude-sonnet-4-6")).toBe(true);
diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.ts
index 6ccae37519..3eda5b284a 100644
--- a/packages/views/runtimes/utils.ts
+++ b/packages/views/runtimes/utils.ts
@@ -159,8 +159,12 @@ const MODEL_PRICING: Record<
string,
{ input: number; output: number; cacheRead: number; cacheWrite: number }
> = {
- // -- Anthropic: current generation. Fable 5 is a Mythos-class SKU at 10/50;
- // Opus 4.5+ stays on the lower 5/25 Opus tier. --
+ // -- Anthropic: current generation. Sonnet 5 uses Anthropic's published
+ // intro launch rate ($2 / $10 through 2026-08-31). This static map has
+ // no future-dated pricing support yet, so update the row when the
+ // post-intro $3 / $15 rate takes effect. Fable 5 is a Mythos-class SKU
+ // at 10/50; Opus 4.5+ stays on the lower 5/25 Opus tier. --
+ "claude-sonnet-5": { input: 2, output: 10, cacheRead: 0.20, cacheWrite: 2.50 },
"claude-fable-5": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },
"claude-haiku-4-5": { input: 1, output: 5, cacheRead: 0.10, cacheWrite: 1.25 },
"claude-sonnet-4-5": { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },
diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.go
index 3ed7122140..0909673a85 100644
--- a/server/internal/metrics/pricing.go
+++ b/server/internal/metrics/pricing.go
@@ -15,11 +15,15 @@ type ModelPrice struct {
}
var modelPrices = map[string]ModelPrice{
- "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.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},
+ // 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.
+ "anthropic:claude-sonnet-5": {Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 10.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-4.8": {Provider: "anthropic", Model: "claude-opus-4.8", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 25.00},
"anthropic:claude-opus-4.7": {Provider: "anthropic", Model: "claude-opus-4.7", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 25.00},
@@ -47,6 +51,7 @@ var modelAliasRules = []struct {
{regexp.MustCompile(`(^|/|:)gpt-5[.-]4-mini($|[^a-z0-9])`), "openai:gpt-5.4-mini"},
{regexp.MustCompile(`(^|/|:)gpt-5[.-]3-codex$`), "openai:gpt-5.3-codex"},
{regexp.MustCompile(`(^|/|:)gpt-5[.-]2-codex$`), "openai:gpt-5.2-codex"},
+ {regexp.MustCompile(`claude-sonnet-5|claude-5-sonnet`), "anthropic:claude-sonnet-5"},
{regexp.MustCompile(`claude-fable-5`), "anthropic:claude-fable-5"},
{regexp.MustCompile(`claude-opus-4[-.]8`), "anthropic:claude-opus-4.8"},
{regexp.MustCompile(`claude-opus-4[-.]7`), "anthropic:claude-opus-4.7"},
diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.go
index e3d4d23dc9..d007933016 100644
--- a/server/internal/metrics/pricing_test.go
+++ b/server/internal/metrics/pricing_test.go
@@ -7,6 +7,18 @@ func TestPriceForModelAliasAnthropicFableAndOpus48(t *testing.T) {
model string
want ModelPrice
}{
+ {
+ model: "claude-sonnet-5",
+ want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
+ },
+ {
+ model: "anthropic:claude-sonnet-5",
+ want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
+ },
+ {
+ model: "claude-5-sonnet",
+ want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
+ },
{
model: "claude-fable-5",
want: ModelPrice{Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10, CacheReadPerM: 1, CacheWritePerM: 12.5, OutputPerM: 50},
diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.go
index af0e50d513..6ac6af0978 100644
--- a/server/pkg/agent/models.go
+++ b/server/pkg/agent/models.go
@@ -287,6 +287,7 @@ func discoveryCacheKey(providerType, executablePath string) string {
// the everyday workhorse (Opus is reserved for advisor-style flows).
func claudeStaticModels() []Model {
return []Model{
+ {ID: "claude-sonnet-5", Label: "Claude Sonnet 5", Provider: "anthropic"},
{ID: "claude-sonnet-4-6", Label: "Claude Sonnet 4.6", Provider: "anthropic", Default: true},
{ID: "claude-fable-5", Label: "Claude Fable 5", Provider: "anthropic"},
{ID: "claude-opus-4-8", Label: "Claude Opus 4.8", Provider: "anthropic"},
diff --git a/server/pkg/agent/models_test.go b/server/pkg/agent/models_test.go
index 4adc8d3157..24b61d1f7f 100644
--- a/server/pkg/agent/models_test.go
+++ b/server/pkg/agent/models_test.go
@@ -80,6 +80,29 @@ func TestClaudeStaticModelsExposesFable5(t *testing.T) {
}
}
+func TestClaudeStaticModelsExposesSonnet5(t *testing.T) {
+ models := claudeStaticModels()
+ ids := map[string]Model{}
+ defaults := 0
+ for _, m := range models {
+ ids[m.ID] = m
+ if m.Default {
+ defaults++
+ }
+ }
+
+ sonnet, ok := ids["claude-sonnet-5"]
+ if !ok {
+ t.Fatalf("missing Claude Sonnet 5 in: %+v", models)
+ }
+ if sonnet.Label != "Claude Sonnet 5" || sonnet.Provider != "anthropic" || sonnet.Default {
+ t.Errorf("unexpected Sonnet 5 entry: %+v", sonnet)
+ }
+ if defaults != 1 || !ids["claude-sonnet-4-6"].Default {
+ t.Errorf("expected Sonnet 4.6 to remain the sole default, got defaults=%d models=%+v", defaults, models)
+ }
+}
+
func TestCodexStaticModelsExposesGPT55(t *testing.T) {
// Codex CLI has no `models list` subcommand so the catalog is
// hand-maintained. Regression guard for multica-ai/multica#2009 —