Skip to content

Custom Gemini API endpoint (AI_CODE_REVIEW_GOOGLE_API_ENDPOINT) is ignored #93

@mcowger

Description

@mcowger

Bug Report

Description

The `AI_CODE_REVIEW_GOOGLE_API_ENDPOINT` environment variable is not respected in two places:

  1. `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.
  2. `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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions