Overview
The Gemini provider enables ZeroClaw to use Google’s Gemini models via either API key or OAuth authentication. Provider ID:gemini
Aliases: google, google-gemini
Public API URL: https://generativelanguage.googleapis.com/v1beta
OAuth Internal API URL: https://cloudcode-pa.googleapis.com/v1internal
Authentication
Priority Order
- Explicit API key from config
GEMINI_API_KEYenvironment variableGOOGLE_API_KEYenvironment variable- Managed OAuth from
auth-profiles.json - Gemini CLI OAuth tokens (
~/.gemini/oauth_creds.json)
API Key Authentication
Get an API key from Google AI Studio:OAuth Authentication (Gemini CLI)
Reuse Gemini CLI credentials:~/.gemini/oauth_creds.json.
Managed OAuth (Auth Profiles)
Use ZeroClaw’s auth system:OAuth Project Resolution
For OAuth users, the GCP project is resolved vialoadCodeAssist endpoint:
- Check
GOOGLE_CLOUD_PROJECTorGOOGLE_CLOUD_PROJECT_ID - Call
https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist - Extract
cloudaicompanionProjectfrom response - Cache for subsequent requests
Configuration
Config File
OAuth Config
Features
Native Tool Calling
Supported: No Gemini does not support native tool calling in the current implementation. Tool requests will fail.Vision Support
Supported: Yes Images are sent as inline data with base64 encoding:Thinking Models
Supported: Yes Thinking models (e.g.,gemini-3-pro-preview) mark reasoning parts with thought: true:
Token Usage Tracking
Supported: Yes Usage data is extracted from response:API Endpoints
Generate Content (API Key)
Endpoint:POST /v1beta/models/{model}:generateContent?key={api_key}
Request:
Generate Content (OAuth)
Endpoint:POST https://cloudcode-pa.googleapis.com/v1internal:generateContent
Authorization: Bearer <oauth_token>
Request:
response field.
Request Configuration
Max Tokens
Default: 8192 Fixed in the provider implementation.Temperature
Range: 0.0 - 2.0 Default: 0.7 (from config)Timeouts
- Request timeout: 120 seconds
- Connection timeout: 10 seconds
Message Format
System Instruction
Sent as top-levelsystemInstruction:
\n\n.
User Messages
Simple text:Assistant Messages
Gemini usesmodel role instead of assistant:
OAuth Token Refresh
Gemini CLI OAuth tokens are automatically refreshed when:- Token expiry is unknown
- Token is already expired
- Token will expire within 60 seconds
https://oauth2.googleapis.com/token
Refresh request:
OAuth Credential Rotation
Multiple OAuth credential files are supported:~/.gemini/oauth_creds.json(primary)~/.gemini-*-home/.gemini/oauth_creds.json(additional)
Stop Reasons
Normalized stop reasons:| Gemini | ZeroClaw Normalized |
|---|---|
STOP | EndTurn |
MAX_TOKENS | MaxTokens |
SAFETY | ContentFilter |
RECITATION | ContentFilter |
Error Handling
Authentication Errors
OAuth Errors
For rate limits or service errors, the provider automatically:- Rotates to next OAuth credential (if available)
- Refreshes the token
- Retries the request
Generation Config Errors
Some OAuth endpoints rejectgenerationConfig. The provider automatically retries without it:
Provider Capabilities
Warmup
Supported: Yes For API key users, warmup calls the/models endpoint:
Example Usage
API Key
OAuth (Gemini CLI)
With Vision
Thinking Model
Authentication Source Diagnostics
Check which credential source is active:"config"- Explicit API key from config"GEMINI_API_KEY env var"- From env var"GOOGLE_API_KEY env var"- From env var"Gemini CLI OAuth"- From~/.gemini/oauth_creds.json"auth-profiles"- Managed OAuth"none"- No credentials
Limitations
- No native tool calling support
- OAuth requires GCP project resolution
- OAuth users must use internal Code Assist API
- Generation config may not work with some OAuth endpoints
- Thinking parts are automatically filtered (not exposed)