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 1 commit
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
1 change: 1 addition & 0 deletions docs/docs/configuration/genai.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ genai:
provider: openai
api_key: "{FRIGATE_OPENAI_API_KEY}"
model: gpt-4o
base_url: https://api.openai.com/v1
skrashevich marked this conversation as resolved.
Show resolved Hide resolved
```

## Azure OpenAI
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 is None or self.genai_config.base_url == "":
self.genai_config.base_url = "https://api.openai.com/v1"
skrashevich marked this conversation as resolved.
Show resolved Hide resolved

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