Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Add settings for custom base url (#2594)

DGdev916ff847811893
diff --git a/.env.template b/.env.template
index f0b3c7cbb5..bf6e2453a2 100644
--- a/.env.template
+++ b/.env.template
@@ -22,6 +22,10 @@ OPENAI_API_KEY=your-openai-api-key
## PROMPT_SETTINGS_FILE - Specifies which Prompt Settings file to use (defaults to prompt_settings.yaml)
# PROMPT_SETTINGS_FILE=prompt_settings.yaml
+## OPENAI_API_BASE_URL - Custom url for the OpenAI API, useful for connecting to custom backends. No effect if USE_AZURE is true, leave blank to keep the default url
+# the following is an example:
+# OPENAI_API_BASE_URL=http://localhost:443/v1
+
## AUTHORISE COMMAND KEY - Key to authorise commands
# AUTHORISE_COMMAND_KEY=y
diff --git a/autogpt/config/config.py b/autogpt/config/config.py
index 3737308cf8..df77b383a7 100644
--- a/autogpt/config/config.py
+++ b/autogpt/config/config.py
@@ -82,6 +82,8 @@ class Config(metaclass=Singleton):
openai.api_type = self.openai_api_type
openai.api_base = self.openai_api_base
openai.api_version = self.openai_api_version
+ elif os.getenv("OPENAI_API_BASE_URL", None):
+ openai.api_base = os.getenv("OPENAI_API_BASE_URL")
if self.openai_organization is not None:
openai.organization = self.openai_organization