package billing import ( "errors" "math" "strings" ) const MinimaxH3Model = "MiniMax-H3" type MinimaxH3ActualAmountInput struct { Resolution string OutputSeconds int64 InputVideoSeconds int64 InputImageCount int64 MarkupMultiplier float64 } func MinimaxH3VideoPriceFenPerSecond(resolution string) int64 { if strings.EqualFold(strings.TrimSpace(resolution), "2K") { return 80 } return 50 } // CalculateMinimaxH3ActualAmountFen follows the official pay-as-you-go H3 // formula. The first five input images are free; this first product release // accepts at most one, while keeping the calculator correct for future modes. func CalculateMinimaxH3ActualAmountFen(input MinimaxH3ActualAmountInput) (int64, error) { if input.OutputSeconds <= 0 { return 0, errors.New("MiniMax H3 output seconds must be positive") } if input.InputVideoSeconds < 0 || input.InputImageCount < 0 { return 0, errors.New("MiniMax H3 input usage must not be negative") } if input.MarkupMultiplier < 1 { return 0, errors.New("MiniMax H3 markup multiplier must be at least 1") } videoSeconds := input.OutputSeconds + input.InputVideoSeconds standardAmountFen := videoSeconds * MinimaxH3VideoPriceFenPerSecond(input.Resolution) if input.InputImageCount > 5 { standardAmountFen += (input.InputImageCount - 5) * 20 } return int64(math.Ceil(float64(standardAmountFen) * input.MarkupMultiplier)), nil } func IsMinimaxH3BillingModel(model string) bool { return strings.EqualFold(strings.TrimSpace(model), MinimaxH3Model) }