diff --git a/connectors/openai-api/openai.go b/connectors/openai-api/openai.go index df58f9b..7f56a73 100644 --- a/connectors/openai-api/openai.go +++ b/connectors/openai-api/openai.go @@ -20,6 +20,11 @@ func GetClient() *openai.Client { transport := &http.Transport{Proxy: http.ProxyURL(proxyUrl)} config.HTTPClient = &http.Client{Transport: transport} } + + if define.OPENAI_API_BASEURL != "" { + config.BaseURL = define.OPENAI_API_BASEURL + } + return openai.NewClientWithConfig(config) } diff --git a/internal/define/define.go b/internal/define/define.go index 75b4cba..aadce3d 100644 --- a/internal/define/define.go +++ b/internal/define/define.go @@ -37,6 +37,7 @@ var ( ENABLE_OPENAI_API = GetBool("ENABLE_OPENAI_API", false) // Enable OpenAI 3.5 API ENABLE_OPENAI_API_ONLY = GetBool("ENABLE_OPENAI_API_ONLY", false) // Only Enable the 3.5 model OPENAI_API_KEY = strings.TrimSpace(os.Getenv("OPENAI_API_KEY")) // OpenAI API Key + OPENAI_API_BASEURL = strings.TrimSpace(os.Getenv("OPENAI_API_BASEURL")) // Custom OpenAI API BASEURL ENABLE_OPENAI_API_PROXY = GetBool("OPENAI_API_PROXY_ENABLE", false) // Enable OpenAI API Proxy OPENAI_API_PROXY_ADDR = GetHostName("OPENAI_API_PROXY_ADDR", DEFAULT_OPENAI_API_PROXY_ADDR) // OpenAI API Proxy Address )