Skip to content

Connect OpenClaw to Google Gemini — 1M Token Context + Free Tier

Let me tell you about the best-kept secret in AI: Google Gemini’s free tier is absurdly generous.

While Claude and GPT charge by the token, Gemini gives you 1 million tokens of context and a solid free tier. If you’re building something that needs to process long documents or maintain extensive conversation history, Gemini is hard to beat.

Here’s how to set it up with OpenClaw.


FeatureGeminiClaudeGPT-4
Free Tier✅ Yes❌ No❌ No
Context Window1M tokens200K tokens128K tokens
Multimodal✅ Images, audio, video✅ Images✅ Images
SpeedFastMediumMedium

  1. Go to Google AI Studio
  2. Sign in with your Google account
  3. Click “Get API Key” → “Create API Key”
  4. Copy the key

Option A: Environment Variable

Terminal window
export GEMINI_API_KEY="your-api-key-here"

Option B: CLI Configuration

Terminal window
openclaw config set models.providers.gemini.apiKey "your-api-key-here"

Edit your OpenClaw config:

{
agents: {
defaults: {
model: { primary: "gemini/gemini-2.5-flash" }
}
}
}

That’s it. You’re now using Gemini.


For more secure, key-free authentication via your Google account:

Option 1: During Onboarding Wizard

  1. Run openclaw onboard
  2. Select “Google” as your AI provider
  3. Choose “OAuth Authentication”
  4. Complete the Google sign-in flow in your browser
  5. OpenClaw stores your auth token securely

Option 2: CLI Plugin Authentication

If you’ve already installed OpenClaw, enable the Gemini CLI auth plugin:

Terminal window
# Enable the Gemini CLI auth plugin
openclaw plugins enable google-gemini-cli-auth
# Authenticate and set as default provider
openclaw models auth login --provider google-gemini-cli --set-default

This opens a browser window for Google OAuth. Once authenticated, you can use Gemini without managing API keys.

Note: OAuth is great for personal use. For automation or server deployments, use an API key instead.


ModelBest ForContext Window
gemini-2.5-flashFast responses1M tokens
gemini-2.5-proComplex reasoning1M tokens
gemini-2.0-flashBalanced128K tokens
{
agents: {
defaults: {
model: {
primary: "gemini/gemini-2.5-flash",
fallback: ["gemini/gemini-2.0-flash"]
}
}
}
}

Google’s free tier includes:

  • 60 requests per minute (Flash models)
  • 2 requests per minute (Pro models)
  • 1 million token context window

For most personal use cases, the free tier is more than enough.

If you hit rate limits, consider:

  • Switching to Flash models for higher limits
  • Adding delays between requests
  • Upgrading to Gemini API paid plan

{
models: {
providers: {
gemini: {
apiKey: "your-api-key",
models: [
{
id: "gemini-2.5-flash",
name: "Gemini 2.5 Flash",
reasoning: false,
input: ["text", "image"],
contextWindow: 1000000,
maxTokens: 8192
}
]
}
}
}
}

Mix Gemini with other models:

{
agents: {
defaults: {
model: {
primary: "gemini/gemini-2.5-flash", // Fast, free
fallback: ["anthropic/claude-sonnet-4"] // For complex tasks
}
}
}
}

Double-check your API key:

  1. Go to Google AI Studio
  2. Verify the key is active
  3. Ensure no extra whitespace when copying

You’ve hit the free tier limit. Options:

  • Wait for the quota to reset (daily)
  • Switch to Flash models for higher limits
  • Upgrade to a paid plan

Verify the model ID:

Terminal window
openclaw models list

Make sure you’re using the correct format: gemini/model-name

Still stuck? Our AI Setup Assistant is trained on all OpenClaw documentation and can help troubleshoot your Gemini setup in real-time.


AspectGeminiClaudeOpenAI
Best ForLong docs, multimodalCreative, nuancedCoding, analysis
Free Tier✅ Generous❌ None❌ None
Context1M tokens200K tokens128K tokens
CodingGoodExcellentExcellent

My recommendation: Use Gemini for document processing and as a cost-effective fallback. Keep Claude or GPT for tasks requiring the best quality output.



Need help? Join the OpenClaw Discord or check the official docs.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.