diff --git a/.env.template b/.env.template index f0b3c7cbb5b..bf6e2453a28 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 3737308cf87..df77b383a72 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -82,6 +82,8 @@ def __init__(self) -> None: 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