package backend import "strings" // Replicate pricing snapshot. // // Source: https://replicate.com/pricing and the per-model "Run" tab on // each model page. Replicate bills per second of GPU time, but the // black-forest-labs FLUX models also publish a flat per-image price for // the typical settings — that flat number is what we hardcode here. // // Snapshot date: 2026-05-08. TODO(refresh): re-check quarterly. If the // rates drift more than ~10%, update the table and bump snapshotDate. const replicatePricingSnapshotDate = "2026-05-08" // replicatePerImageUSD is the per-image cost estimate keyed by Replicate // model identifier ("owner/name", with any ":version" trimmed). Returns // the rate and true if the model is known, 0 and false otherwise — an // unknown model writes a row with NULL cost rather than a wrong number. func replicatePerImageUSD(model string) (float64, bool) { key := normalisePricingKey(model) switch key { case "black-forest-labs/flux-schnell": return 0.003, true case "black-forest-labs/flux-dev": return 0.025, true case "black-forest-labs/flux-pro": return 0.055, true case "black-forest-labs/flux-1.1-pro": return 0.040, true } return 0, false } // normalisePricingKey strips the optional ":version" suffix and lowercases // the owner/name pair. "Owner/Name:hash" → "owner/name". func normalisePricingKey(model string) string { if i := strings.IndexByte(model, ':'); i >= 0 { model = model[:i] } return strings.ToLower(model) }