-
Notifications
You must be signed in to change notification settings - Fork 6
Custom Gemini API endpoint (AI_CODE_REVIEW_GOOGLE_API_ENDPOINT) is ignored #93
Copy link
Copy link
Open
Description
Bug Report
Description
The `AI_CODE_REVIEW_GOOGLE_API_ENDPOINT` environment variable is not respected in two places:
- `geminiClient.ts` — when calling `getGenerativeModel()`, the custom base URL is never passed to the SDK, so all API calls always go to the default Google endpoint regardless of the env var.
- `apiKeyHealthCheck.ts` — the health check that validates the Google API key always uses the hardcoded URL `https://generativelanguage.googleapis.com/v1beta/models\`, ignoring the custom endpoint entirely.
This means users who configure a custom endpoint (e.g. for proxies, private deployments, or regional endpoints) will have their health checks pass or fail against the wrong host, and their actual review calls will still hit the default Google endpoint.
Steps to Reproduce
```bash
export AI_CODE_REVIEW_GOOGLE_API_ENDPOINT=https://my-custom-endpoint.example.com
ai-code-review . --type quick-fixes
```
Expected: All Gemini API calls and key validation use `https://my-custom-endpoint.example.com\`.
Actual: All calls go to `https://generativelanguage.googleapis.com\` regardless.
Root Cause
- In `geminiClient.ts`, `genAI.getGenerativeModel()` is called without the optional `RequestOptions` second argument that carries `baseUrl`.
- In `apiKeyHealthCheck.ts`, the validation URL is hardcoded rather than reading from `AI_CODE_REVIEW_GOOGLE_API_ENDPOINT`.
Proposed Fix
- Read `AI_CODE_REVIEW_GOOGLE_API_ENDPOINT` and pass `{ baseUrl: customEndpoint }` as the second argument to `getGenerativeModel()`.
- Update `validateGoogleApiKey()` to build the validation URL from the same env var, falling back to the default endpoint.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels