Nexus
1.x
Docs/Nexus/Google Vertex AI
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/providers/vertex.mdx

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.

Installation01

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

Quick Start02

// 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),
)

Options03

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

Capabilities04

CapabilitySupported
ChatYes
StreamingYes
EmbeddingsYes
VisionYes
ToolsYes
ThinkingNo

Authentication05

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")),
)

Models06

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