Nexus

Google Vertex AI

Use Vertex AI-hosted Gemini models with Nexus — GCP OAuth2 auth with project/location routing.

The Vertex AI provider connects to Google Cloud's Vertex AI platform. It uses the same Gemini API format but with OAuth2 Bearer token authentication and project/location-based URL routing.

Installation

import "github.com/xraph/nexus/providers/vertex"

Quick Start

// With service account credentials (recommended)
creds, _ := os.ReadFile("service-account.json")
provider := vertex.New(
    vertex.WithProjectID("my-project"),
    vertex.WithLocation("us-central1"),
    vertex.WithCredentialsJSON(creds),
)

gw := nexus.New(
    nexus.WithProvider(provider),
)

Options

OptionDescription
vertex.WithProjectID(id)Google Cloud project ID
vertex.WithLocation(loc)GCP region (default: us-central1)
vertex.WithAccessToken(token)Static OAuth2 access token
vertex.WithCredentialsJSON(json)Service account JSON for automatic token management
vertex.WithBaseURL(url)Override the full base URL directly

Capabilities

CapabilitySupported
ChatYes
StreamingYes
EmbeddingsYes
VisionYes
ToolsYes
ThinkingNo

Authentication

Vertex AI uses Google Cloud OAuth2 instead of API keys:

// Option 1: Service account JSON (auto-refreshing tokens)
creds, _ := os.ReadFile("service-account.json")
provider := vertex.New(
    vertex.WithProjectID("my-project"),
    vertex.WithCredentialsJSON(creds),
)

// Option 2: Static access token (e.g., from gcloud auth)
provider := vertex.New(
    vertex.WithProjectID("my-project"),
    vertex.WithAccessToken(os.Getenv("GCLOUD_ACCESS_TOKEN")),
)

Models

ModelContextMax OutputInput PriceOutput Price
gemini-2.0-flash1M8,192$0.10/M$0.40/M
gemini-1.5-pro2M8,192$1.25/M$5.00/M
text-embedding-0042,048$0.025/M

On this page