summaryrefslogtreecommitdiff
path: root/internal/cli/apikeys.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/apikeys.go')
-rw-r--r--internal/cli/apikeys.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/cli/apikeys.go b/internal/cli/apikeys.go
new file mode 100644
index 0000000..0bcaa49
--- /dev/null
+++ b/internal/cli/apikeys.go
@@ -0,0 +1,35 @@
+package cli
+
+import (
+ "os"
+
+ "github.com/spf13/viper"
+)
+
+// GetOpenAIKey retrieves the OpenAI API key from environment or config
+func GetOpenAIKey() string {
+ // First check environment variable
+ if key := os.Getenv("OPENAI_API_KEY"); key != "" {
+ return key
+ }
+
+ // Then check config file
+ return viper.GetString("audio.openai_key")
+}
+
+// GetGoogleAPIKey retrieves the Google API key from GOOGLE_API_KEY or config.
+// It prefers image.google_api_key and falls back to google.api_key for older configs.
+func GetGoogleAPIKey() string {
+ // First check environment variable
+ if key := os.Getenv("GOOGLE_API_KEY"); key != "" {
+ return key
+ }
+
+ // Then check config file
+ if key := viper.GetString("image.google_api_key"); key != "" {
+ return key
+ }
+
+ // Fall back to the legacy key for compatibility with older configs.
+ return viper.GetString("google.api_key")
+}