|
|
@@ -117,11 +117,20 @@ func ImageHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *type
|
|
|
if request.N != nil {
|
|
|
imageN = *request.N
|
|
|
}
|
|
|
+
|
|
|
+ // n is handled via OtherRatio so it is applied exactly once in quota
|
|
|
+ // calculation (both price-based and ratio-based paths).
|
|
|
+ // Adaptors may have already set a more accurate count from the
|
|
|
+ // upstream response; only set the default when they haven't.
|
|
|
+ if _, hasN := info.PriceData.OtherRatios["n"]; !hasN {
|
|
|
+ info.PriceData.AddOtherRatio("n", float64(imageN))
|
|
|
+ }
|
|
|
+
|
|
|
if usage.(*dto.Usage).TotalTokens == 0 {
|
|
|
- usage.(*dto.Usage).TotalTokens = int(imageN)
|
|
|
+ usage.(*dto.Usage).TotalTokens = 1
|
|
|
}
|
|
|
if usage.(*dto.Usage).PromptTokens == 0 {
|
|
|
- usage.(*dto.Usage).PromptTokens = int(imageN)
|
|
|
+ usage.(*dto.Usage).PromptTokens = 1
|
|
|
}
|
|
|
|
|
|
quality := "standard"
|