summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-12-13 12:26:57 +0300
committerGrail Finder <wohilas@gmail.com>2025-12-13 12:26:57 +0300
commite481661799f3400732fa891c91192d09cc48b867 (patch)
tree9c51b126f564bf260960c2ad8ca5ffcab96e8064
parent6fd6e7741590e99a6a2ac0f634937452756c7400 (diff)
Enha: option to pass api token through envHEADmaster
-rw-r--r--config/config.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/config/config.go b/config/config.go
index 681757d..eef8035 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1,6 +1,8 @@
package config
import (
+ "os"
+
"github.com/BurntSushi/toml"
)
@@ -84,6 +86,13 @@ func LoadConfig(fn string) (*Config, error) {
config.OpenRouterCompletionAPI: config.OpenRouterChatAPI,
config.OpenRouterChatAPI: config.ChatAPI,
}
+ // check env if keys not in config
+ if config.OpenRouterToken == "" {
+ config.OpenRouterToken = os.Getenv("OPENROUTER_API_KEY")
+ }
+ if config.DeepSeekToken == "" {
+ config.DeepSeekToken = os.Getenv("DEEPSEEK_API_KEY")
+ }
// Build ApiLinks slice with only non-empty API links
// Only include DeepSeek APIs if DeepSeekToken is provided
if config.DeepSeekToken != "" {
@@ -94,7 +103,6 @@ func LoadConfig(fn string) (*Config, error) {
config.ApiLinks = append(config.ApiLinks, config.DeepSeekCompletionAPI)
}
}
-
// Only include OpenRouter APIs if OpenRouterToken is provided
if config.OpenRouterToken != "" {
if config.OpenRouterChatAPI != "" {
@@ -104,7 +112,6 @@ func LoadConfig(fn string) (*Config, error) {
config.ApiLinks = append(config.ApiLinks, config.OpenRouterCompletionAPI)
}
}
-
// Always include basic APIs
if config.ChatAPI != "" {
config.ApiLinks = append(config.ApiLinks, config.ChatAPI)