mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 23:07:18 +00:00
- alpha/search 成功请求(上游 2xx)按次计费落 usage_logs(billing_mode=per_request), 上游错误透传/failover 不计费;使用 mandatory 池提交,池满同步兜底不丢扣费 - 单价默认 0.01 USD/次(官方 $10/1000 次),分组新增 web_search_price_per_call 覆盖价(0=免费,负数/留空=默认价),实际扣费叠加分组费率倍数(与 token 口径一致) - 分组字段全链路:ent schema + 迁移 174 + 端口快照 v15 + admin 创建/更新 + DTO - 前端分组表单(openai 平台)新增单次价格配置,实时预览应用当前倍率后的单次价格 - 该端点鉴权维持仅 OpenAI 分组(非 OpenAI 分组 404)
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package service
|
|
|
|
func imagePriceConfigFromAPIKey(apiKey *APIKey) *ImagePriceConfig {
|
|
if apiKey == nil || apiKey.Group == nil {
|
|
return nil
|
|
}
|
|
return &ImagePriceConfig{
|
|
Price1K: apiKey.Group.ImagePrice1K,
|
|
Price2K: apiKey.Group.ImagePrice2K,
|
|
Price4K: apiKey.Group.ImagePrice4K,
|
|
}
|
|
}
|
|
|
|
func apiKeyHasConfiguredImagePrice(apiKey *APIKey, imageSize string) bool {
|
|
return apiKey != nil && apiKey.Group != nil && apiKey.Group.GetImagePrice(imageSize) != nil
|
|
}
|
|
|
|
func videoPriceConfigFromAPIKey(apiKey *APIKey) *VideoPriceConfig {
|
|
if apiKey == nil || apiKey.Group == nil {
|
|
return nil
|
|
}
|
|
return &VideoPriceConfig{
|
|
Price480P: apiKey.Group.VideoPrice480P,
|
|
Price720P: apiKey.Group.VideoPrice720P,
|
|
Price1080P: apiKey.Group.VideoPrice1080P,
|
|
}
|
|
}
|
|
|
|
func apiKeyHasConfiguredVideoPrice(apiKey *APIKey, resolution string) bool {
|
|
return apiKey != nil && apiKey.Group != nil && apiKey.Group.GetVideoPrice(resolution) != nil
|
|
}
|
|
|
|
func webSearchPricePerCallFromAPIKey(apiKey *APIKey) *float64 {
|
|
if apiKey == nil || apiKey.Group == nil {
|
|
return nil
|
|
}
|
|
return apiKey.Group.WebSearchPricePerCall
|
|
}
|