From ce29ccda8d90a78e53be295a30e4cdfd369c254d Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Wed, 13 Nov 2024 16:11:34 +0300 Subject: [PATCH] docs(configuration): document optional base_url parameter for OpenAI Add explanation for the optional base_url parameter in genai.md, allowing custom endpoint configuration for OpenAI API. Update logic in openai.py to handle empty string by setting base_url to None. --- docs/docs/configuration/genai.md | 5 ++++- frigate/genai/openai.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/docs/configuration/genai.md b/docs/docs/configuration/genai.md index 68ea054d1..89405360d 100644 --- a/docs/docs/configuration/genai.md +++ b/docs/docs/configuration/genai.md @@ -112,9 +112,12 @@ genai: provider: openai api_key: "{FRIGATE_OPENAI_API_KEY}" model: gpt-4o - base_url: https://api.openai.com/v1 + base_url: http://example.endpoint/v1 # optional ``` +### Optional base_url Parameter +The base_url parameter is an optional configuration setting that allows you to specify a custom endpoint for the OpenAI API. By default, the OpenAI client uses the standard API endpoint provided by OpenAI. However, if you need to route your requests through a different server or use a proxy, you can set this parameter to the desired URL. + ## Azure OpenAI Microsoft offers several vision models through Azure OpenAI. A subscription is required. diff --git a/frigate/genai/openai.py b/frigate/genai/openai.py index 0d3ecaf65..ffc993d6c 100644 --- a/frigate/genai/openai.py +++ b/frigate/genai/openai.py @@ -22,8 +22,8 @@ class OpenAIClient(GenAIClient): def _init_provider(self): """Initialize the client.""" - if self.genai_config.base_url is None or self.genai_config.base_url == "": - self.genai_config.base_url = "https://api.openai.com/v1" + if self.genai_config.base_url == "": + self.genai_config.base_url = None return OpenAI( api_key=self.genai_config.api_key, base_url=self.genai_config.base_url