Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Price reviewed OpenRouter qualification routes

rcourtmand1e8aece7d7a
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 587bd53a5d..61c89dcefa 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5663,6 +5663,12 @@ Qualification scoring must keep synthetic Patrol runtime findings on the
Provider/runtime failure remains an unconditional qualification hard failure,
but its synthetic service finding must not be reported as an infrastructure
false positive or matched to scenario ground truth.
+Qualification cost gates must resolve the configured provider route rather
+than silently borrowing a direct-provider family price. Reviewed OpenRouter
+routes use exact model IDs and model-specific review dates from the public
+OpenRouter Models API; aliases, fast variants, routers, and other unreviewed
+routes remain unknown and therefore fail any non-zero qualification cost
+budget until their actual route price is explicitly recorded.
Persisted Patrol tool inputs must retain complete structured finding calls up
to the bounded 16 KiB record limit so normal evidence-rich findings remain
deterministically replayable. If any captured input is nevertheless incomplete
diff --git a/internal/ai/cost/coverage_test.go b/internal/ai/cost/coverage_test.go
index 948859a407..6fa19493a0 100644
--- a/internal/ai/cost/coverage_test.go
+++ b/internal/ai/cost/coverage_test.go
@@ -128,6 +128,39 @@ func TestLookupPriceUsesTieredGeminiPricing(t *testing.T) {
}
}
+func TestLookupPriceUsesReviewedOpenRouterRoutes(t *testing.T) {
+ tests := []struct {
+ model string
+ input float64
+ output float64
+ }{
+ {model: "anthropic/claude-opus-4.8", input: 5.00, output: 25.00},
+ {model: "anthropic/claude-sonnet-5", input: 2.00, output: 10.00},
+ {model: "deepseek/deepseek-v4-flash", input: 0.09, output: 0.18},
+ }
+ for _, test := range tests {
+ t.Run(test.model, func(t *testing.T) {
+ price, ok := lookupPrice("openrouter", test.model, 50_000)
+ if !ok {
+ t.Fatal("expected reviewed OpenRouter route pricing to resolve")
+ }
+ if price.InputUSDPerMTok != test.input || price.OutputUSDPerMTok != test.output {
+ t.Fatalf("unexpected OpenRouter price: %+v", price)
+ }
+ if price.AsOf != "2026-07-14" {
+ t.Fatalf("unexpected OpenRouter pricing date %q", price.AsOf)
+ }
+ })
+ }
+
+ if _, ok := lookupPrice("openrouter", "anthropic/claude-opus-4.8-fast", 50_000); ok {
+ t.Fatal("expected unreviewed OpenRouter route variant to remain unknown")
+ }
+ if _, ok := lookupPrice("openrouter", "openrouter/auto", 50_000); ok {
+ t.Fatal("expected dynamic OpenRouter alias pricing to remain unknown")
+ }
+}
+
func TestSetPersistence_LoadError(t *testing.T) {
store := NewStore(30)
mock := &savePersistence{loadErr: errors.New("load failed")}
diff --git a/internal/ai/cost/pricing.go b/internal/ai/cost/pricing.go
index 3b6826973c..0dc5d661dc 100644
--- a/internal/ai/cost/pricing.go
+++ b/internal/ai/cost/pricing.go
@@ -26,6 +26,7 @@ func EstimateUSD(provider, model string, inputTokens, outputTokens int64) (usd f
type modelPrice struct {
Pattern string
Tiers []priceTier
+ AsOf string
}
type priceTier struct {
@@ -60,6 +61,15 @@ var providerPrices = map[string][]modelPrice{
flatPrice("deepseek-v4-pro*", 0.435, 0.87),
flatPrice("deepseek-*", 0.14, 0.28),
},
+ "openrouter": {
+ // OpenRouter model-catalog list prices, checked from the public Models API
+ // (https://openrouter.ai/api/v1/model/:author/:slug) on 2026-07-14.
+ // Keep these route-specific: OpenRouter aliases, variants, and provider
+ // routing can have different prices and must remain unknown until reviewed.
+ flatPriceAsOf("anthropic/claude-opus-4.8", 5.00, 25.00, "2026-07-14"),
+ flatPriceAsOf("anthropic/claude-sonnet-5", 2.00, 10.00, "2026-07-14"),
+ flatPriceAsOf("deepseek/deepseek-v4-flash", 0.09, 0.18, "2026-07-14"),
+ },
"gemini": {
// Gemini Developer API standard paid-tier pricing, checked from
// https://ai.google.dev/gemini-api/docs/pricing on 2026-06-04.
@@ -99,6 +109,12 @@ func flatPrice(pattern string, inputUSDPerMTok, outputUSDPerMTok float64) modelP
}
}
+func flatPriceAsOf(pattern string, inputUSDPerMTok, outputUSDPerMTok float64, asOf string) modelPrice {
+ price := flatPrice(pattern, inputUSDPerMTok, outputUSDPerMTok)
+ price.AsOf = asOf
+ return price
+}
+
func tieredPrice(pattern string, tiers ...priceTier) modelPrice {
return modelPrice{
Pattern: pattern,
@@ -124,10 +140,14 @@ func lookupPrice(provider, model string, inputTokens int64) (TokenPrice, bool) {
if !ok {
return TokenPrice{}, false
}
+ asOf := p.AsOf
+ if asOf == "" {
+ asOf = pricingAsOf
+ }
return TokenPrice{
InputUSDPerMTok: tier.InputUSDPerMTok,
OutputUSDPerMTok: tier.OutputUSDPerMTok,
- AsOf: pricingAsOf,
+ AsOf: asOf,
}, true
}
}