-
Notifications
You must be signed in to change notification settings - Fork 62
feat: add support for custom openai base url #44
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for configuring a custom OpenAI base URL, enabling users to connect to OpenAI-compatible endpoints (such as Azure OpenAI, local proxies, or other API-compatible services) instead of being limited to the default OpenAI API endpoint.
Key changes:
- Added
OPENAI_BASE_URLenvironment variable configuration with a sensible default - Updated the OpenAI client initialization to use the configured base URL
- Extended Helm chart deployment configuration to support the new setting
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/libs/cfg/cfg.go |
Added OpenAIBaseURL field to config struct and openAIBaseURL() helper function that reads from env var with default fallback |
internal/services/toolkit/client/client.go |
Updated OpenAI client initialization to use the configured base URL via option.WithBaseURL() |
helm-chart/values.yaml |
Added openai_base_url value with default OpenAI endpoint |
helm-chart/templates/paperdebugger.yaml |
Added OPENAI_BASE_URL environment variable to ConfigMap for Kubernetes deployment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func openAIBaseURL() string { | ||
| val := os.Getenv("OPENAI_BASE_URL") | ||
| if val != "" { | ||
| return val | ||
| } | ||
| return "https://api.openai.com/v1" | ||
| } |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new OpenAIBaseURL field and openAIBaseURL() helper function lack test coverage. The existing test file cfg_test.go validates other configuration fields (MongoURI, JwtSigningKey, OpenAIAPIKey) but doesn't include assertions for the new OpenAIBaseURL field.
Consider adding test coverage similar to the existing assertions:
assert.NotNil(t, cfg.OpenAIBaseURL)
assert.NotEmpty(t, cfg.OpenAIBaseURL)Additionally, consider testing both the default value and custom value scenarios for the openAIBaseURL() function to ensure it correctly falls back to the default when the environment variable is not set.
| func openAIBaseURL() string { | ||
| val := os.Getenv("OPENAI_BASE_URL") | ||
| if val != "" { | ||
| return val | ||
| } | ||
| return "https://api.openai.com/v1" | ||
| } |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The openAIBaseURL() function doesn't trim whitespace from the environment variable value. If a user accidentally includes leading/trailing whitespace in the OPENAI_BASE_URL environment variable, it could cause API connection issues.
Consider applying strings.TrimSpace() to the value before returning it, consistent with how other URL values might be handled:
func openAIBaseURL() string {
val := os.Getenv("OPENAI_BASE_URL")
if val != "" {
return strings.TrimSpace(val)
}
return "https://api.openai.com/v1"
}Note: You'll need to import "strings" if not already imported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Allow change openai base url to a custom endpoint.