media_price_config.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package service
  2. func imagePriceConfigFromAPIKey(apiKey *APIKey) *ImagePriceConfig {
  3. if apiKey == nil || apiKey.Group == nil {
  4. return nil
  5. }
  6. return &ImagePriceConfig{
  7. Price1K: apiKey.Group.ImagePrice1K,
  8. Price2K: apiKey.Group.ImagePrice2K,
  9. Price4K: apiKey.Group.ImagePrice4K,
  10. }
  11. }
  12. func apiKeyHasConfiguredImagePrice(apiKey *APIKey, imageSize string) bool {
  13. return apiKey != nil && apiKey.Group != nil && apiKey.Group.GetImagePrice(imageSize) != nil
  14. }
  15. func videoPriceConfigFromAPIKey(apiKey *APIKey) *VideoPriceConfig {
  16. if apiKey == nil || apiKey.Group == nil {
  17. return nil
  18. }
  19. return &VideoPriceConfig{
  20. Price480P: apiKey.Group.VideoPrice480P,
  21. Price720P: apiKey.Group.VideoPrice720P,
  22. Price1080P: apiKey.Group.VideoPrice1080P,
  23. ModelPrices: apiKey.Group.VideoModelPrices,
  24. }
  25. }
  26. func apiKeyHasConfiguredVideoPrice(apiKey *APIKey, model, resolution string) bool {
  27. return apiKey != nil && apiKey.Group != nil && apiKey.Group.GetVideoPriceForModel(model, resolution) != nil
  28. }
  29. func webSearchPricePerCallFromAPIKey(apiKey *APIKey) *float64 {
  30. if apiKey == nil || apiKey.Group == nil {
  31. return nil
  32. }
  33. return apiKey.Group.WebSearchPricePerCall
  34. }
  35. func groupSearchPricePer1kFromAPIKey(apiKey *APIKey) *float64 {
  36. if apiKey == nil || apiKey.Group == nil {
  37. return nil
  38. }
  39. return apiKey.Group.GetSearchPricePer1k()
  40. }
  41. func groupAudioPriceConfigFromAPIKey(apiKey *APIKey) *audioPriceConfig {
  42. if apiKey == nil || apiKey.Group == nil {
  43. return nil
  44. }
  45. g := apiKey.Group
  46. return &audioPriceConfig{
  47. RealtimePerMin: g.AudioRealtimePricePerMin,
  48. TTSPerMChars: g.AudioTTSPricePerMillionChars,
  49. STTPerHour: g.AudioSTTPricePerHour,
  50. }
  51. }