Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(genai): add configurable base_url for OpenAI API integration #14953

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/docs/configuration/genai.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ genai:
provider: openai
api_key: "{FRIGATE_OPENAI_API_KEY}"
model: gpt-4o
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.
Expand Down
8 changes: 7 additions & 1 deletion frigate/genai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ class OpenAIClient(GenAIClient):

def _init_provider(self):
"""Initialize the client."""
return OpenAI(api_key=self.genai_config.api_key)

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
)

def _send(self, prompt: str, images: list[bytes]) -> Optional[str]:
"""Submit a request to OpenAI."""
Expand Down
Loading