[PR #10303] feat: add openai-compatible endpoint support for google-vertex provider #13394

Closed
opened 2026-02-16 18:18:15 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10303

State: closed
Merged: Yes


Summary

Adds a new google-vertex-openapi provider that enables using third-party models (like GLM-4.7) on Google Vertex AI through the OpenAPI-compatible endpoint.

Fixes #10304

Changes

Provider Implementation (src/provider/provider.ts):

  • Replaced gcloud CLI subprocess approach with Application Default Credentials (ADC) using google-auth-library
    • No subprocess overhead (performance improvement)
    • Automatic token refresh (handled by library)
    • Supports multiple credential sources (gcloud ADC, service account, etc.)
  • Added getModel function for consistency with other providers

Test Infrastructure (test/provider/provider.test.ts):

  • Mocked google-auth-library for testing support

  • Configuration:

    • Environment variables: GOOGLE_CLOUD_PROJECT, GCP_PROJECT, GCLOUD_PROJECT (project)
    • Environment variables: GOOGLE_CLOUD_LOCATION, VERTEX_LOCATION (location)
    • Config options: provider.options.project, provider.options.location
  • Authentication:

    • Works with gcloud auth application-default login (easiest for development)
    • Supports GOOGLE_APPLICATION_CREDENTIALS for service accounts (production)

Verification

  • Typecheck: Passed
  • Tests: All passing (pre-existing failures unaffected)
  • Manual testing: Can configure provider and make requests to Vertex AI OpenAPI endpoint

Usage

{
  "provider": {
    "google-vertex-openapi": {
      "name": "Google Vertex AI (OpenAPI)",
      "npm": "@ai-sdk/openai-compatible",
      "api": "https://aiplatform.googleapis.com/v1beta1",
      "options": {
        "project": "my-project-id",
        "location": "global"
      },
      "models": {
        "glm-4.7": {
          "name": "GLM-4.7",
          "tool_call": true,
          "reasoning": true,
          "limit": {"context": 128000, "output": 8192}
        }
      }
    }
  }
}

Setup

# Using gcloud ADC (recommended for development)
gcloud auth application-default login
export GOOGLE_CLOUD_PROJECT=my-project-id

# OR using service account (recommended for production)
export GOOGLE_APPLICATION_CREDENTIALS=~/.config/google/vertex-ai-service-account.json
export GOOGLE_CLOUD_PROJECT=my-project-id
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10303 **State:** closed **Merged:** Yes --- ## Summary Adds a new `google-vertex-openapi` provider that enables using third-party models (like GLM-4.7) on Google Vertex AI through the OpenAPI-compatible endpoint. Fixes #10304 ## Changes **Provider Implementation** (`src/provider/provider.ts`): - Replaced gcloud CLI subprocess approach with Application Default Credentials (ADC) using `google-auth-library` - No subprocess overhead (performance improvement) - Automatic token refresh (handled by library) - Supports multiple credential sources (gcloud ADC, service account, etc.) - Added `getModel` function for consistency with other providers **Test Infrastructure** (`test/provider/provider.test.ts`): - Mocked `google-auth-library` for testing support - **Configuration**: - Environment variables: `GOOGLE_CLOUD_PROJECT`, `GCP_PROJECT`, `GCLOUD_PROJECT` (project) - Environment variables: `GOOGLE_CLOUD_LOCATION`, `VERTEX_LOCATION` (location) - Config options: `provider.options.project`, `provider.options.location` - **Authentication**: - Works with `gcloud auth application-default login` (easiest for development) - Supports `GOOGLE_APPLICATION_CREDENTIALS` for service accounts (production) ## Verification - Typecheck: Passed - Tests: All passing (pre-existing failures unaffected) - Manual testing: Can configure provider and make requests to Vertex AI OpenAPI endpoint ## Usage ```json { "provider": { "google-vertex-openapi": { "name": "Google Vertex AI (OpenAPI)", "npm": "@ai-sdk/openai-compatible", "api": "https://aiplatform.googleapis.com/v1beta1", "options": { "project": "my-project-id", "location": "global" }, "models": { "glm-4.7": { "name": "GLM-4.7", "tool_call": true, "reasoning": true, "limit": {"context": 128000, "output": 8192} } } } } } ``` ## Setup ```bash # Using gcloud ADC (recommended for development) gcloud auth application-default login export GOOGLE_CLOUD_PROJECT=my-project-id # OR using service account (recommended for production) export GOOGLE_APPLICATION_CREDENTIALS=~/.config/google/vertex-ai-service-account.json export GOOGLE_CLOUD_PROJECT=my-project-id ```
yindo added the pull-request label 2026-02-16 18:18:15 -05:00
yindo closed this issue 2026-02-16 18:18:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13394