Skip to main content

Google (Gemini)

Google provides the Gemini model family for text, vision, and reasoning. OpenClaw supports two authentication paths: a GEMINI_API_KEY for direct API access, and the Google Gemini CLI OAuth flow for users who prefer browser-based sign-in.

Requirements

  • A Gemini API key from aistudio.google.com, or
  • A Google account with access to Gemini (for OAuth via google-gemini-cli)

Quickstart

API key

Google Gemini CLI OAuth

This opens a browser-based OAuth flow. Keep the terminal open until it completes. After either method, verify the setup:

Configuration

Environment variable

OpenClaw reads GEMINI_API_KEY automatically and enables the google provider.

Config snippet

Provider settings

Available models

The google provider includes all current Gemini models. Key models: Use model IDs as google/<model-id> (example: google/gemini-2.5-pro).

Vertex AI

For enterprise Vertex AI access, use the google-vertex provider. Authentication resolves in this order:
  1. GOOGLE_CLOUD_API_KEY — explicit Vertex API key.
  2. Application Default Credentials (ADC), configured with gcloud:
The ADC path requires three things: credentials (the gcloud ADC file, or GOOGLE_APPLICATION_CREDENTIALS pointing at a service account key file), GOOGLE_CLOUD_PROJECT (or GCLOUD_PROJECT), and GOOGLE_CLOUD_LOCATION. Without the project or location, requests fail with Vertex AI requires a project ID / Vertex AI requires a location. google-vertex also honors the Gemini key pool for key-rotated workloads: GEMINI_API_KEYS (comma-separated), GEMINI_API_KEY, GEMINI_API_KEY_<n>, and GOOGLE_API_KEY (fallback). The base URL is https://{location}-aiplatform.googleapis.com and uses the google-vertex API backend.

google-vertex config snippet

Available google-vertex models mirror most google models: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-3-pro-preview, gemini-3-flash-preview, gemini-2.0-flash, gemini-2.0-flash-lite, gemini-1.5-pro, gemini-1.5-flash, gemini-1.5-flash-8b, gemini-3.1-pro-preview.

Troubleshooting

401 Unauthorized / API key not valid
  • Verify your API key starts with AIza and is copied in full.
  • Re-run onboarding: openclaw onboard --auth-choice gemini-api-key.
  • Ensure the Generative Language API is enabled in your Google Cloud project.
OAuth token refresh failed
  • Re-run openclaw onboard --auth-choice google-gemini-cli to refresh the OAuth token.
Model ID not found
  • Use openclaw models list to see available model IDs.
  • OpenClaw normalizes some model IDs: gemini-3-progemini-3-pro-preview, gemini-3-flashgemini-3-flash-preview.
Vertex AI: no credentials
  • Run gcloud auth application-default login to authenticate, or set GOOGLE_APPLICATION_CREDENTIALS to a service account key file.
  • ADC also requires GOOGLE_CLOUD_PROJECT (or GCLOUD_PROJECT) and GOOGLE_CLOUD_LOCATION; missing either fails credential resolution.
  • To skip ADC, set GOOGLE_CLOUD_API_KEY with an explicit Vertex API key.