---
title: "How to Use Google Gemini with OpenClaw (API Key Setup, 2026)"
description: "Get a Gemini API key, add Google as a provider in OpenClaw, pick a model, and handle the free-tier limits. Copy-paste config plus a one-key alternative."
date: 2026-05-11
location: San Francisco, CA – May 11th, 2026
image: /images/gemini-api-key-openclaw-hero.jpg
keywords: "openclaw gemini api key, openclaw gemini api, openclaw add gemini, gemini with openclaw, openclaw google gemini setup, openclaw gemini provider, how to use gemini with openclaw"
faq:
  - question: "How do I add a Gemini API key to OpenClaw?"
    answer: "Get a key from Google AI Studio (aistudio.google.com), then open ~/.openclaw/openclaw.json and add a 'google' entry under models.providers with baseUrl 'https://generativelanguage.googleapis.com/v1beta', your apiKey, and api 'openai-completions'. Add the Gemini models you want to the allowlist, then select one with /model in OpenClaw. The 'openclaw onboard' wizard can do this for you interactively."
  - question: "Is the Gemini API free to use with OpenClaw?"
    answer: "Google AI Studio gives every key a free tier with generous daily request limits, which is enough for light OpenClaw use at zero cost. Past those limits you're billed per token — roughly $0.10–$2 per million input tokens depending on the model. Gemini 2.0 Flash is the cheapest; Gemini 3.1 Pro costs the most."
  - question: "Which Gemini model should I use with OpenClaw?"
    answer: "Use Gemini 3 Flash as your default — it's cheap, fast, and capable enough for most tasks, with a 1M-token context window. Switch to Gemini 3.1 Pro for hard debugging and reasoning, or Gemini 2.0 Flash when you want to stay inside the free tier. All three have the 1M context that makes Gemini worth configuring in the first place."
---

OpenClaw treats Google Gemini as a first-party provider, so adding it is mostly a matter of pasting an API key into the right place. Here's the whole flow — get the key, wire it up, pick a model — plus the one-key shortcut if you don't want a separate Google account.

## 1. Get a Gemini API key

1. Go to [Google AI Studio](https://aistudio.google.com).
2. Sign in with your Google account.
3. Open the **API Keys** section and create a key.
4. Copy it somewhere safe — you'll paste it into the OpenClaw config in a second.

Every key comes with a free tier: a generous number of requests per day at no cost. That's enough for light OpenClaw use without ever being billed. Beyond the free limits you pay per token.

## 2. Add Google as a provider in OpenClaw

Open `~/.openclaw/openclaw.json` and add a `google` entry under `models.providers`:

```json
{
  "models": {
    "providers": {
      "google": {
        "baseUrl": "https://generativelanguage.googleapis.com/v1beta",
        "apiKey": "your-google-api-key",
        "api": "openai-completions"
      }
    }
  }
}
```

If you'd rather not edit the file by hand, run `openclaw onboard` — the wizard walks you through picking Google and entering the key, and writes the config for you.

## 3. Add the Gemini models you want

In the same file, allowlist the models under the provider:

```json
{
  "models": {
    "providers": {
      "google": {
        "baseUrl": "https://generativelanguage.googleapis.com/v1beta",
        "apiKey": "your-google-api-key",
        "api": "openai-completions",
        "models": [
          { "id": "gemini-3-flash", "name": "Gemini 3 Flash" },
          { "id": "gemini-3.1-pro", "name": "Gemini 3.1 Pro" }
        ]
      }
    }
  }
}
```

Then start OpenClaw and run `/model` to switch to a Gemini model, or set it as your default under `agents.defaults.model.primary` (e.g. `"google/gemini-3-flash"`).

## Which Gemini model to pick

| Model | Input / Output (per 1M) | Context | Use it for |
|---|---|---|---|
| **Gemini 3 Flash** | ~$0.50 / $3 | 1M | Default — cheap, fast, handles most tasks |
| **Gemini 3.1 Pro** | ~$2 / $12 | 1M | Hard debugging, deeper reasoning, codebase Q&A |
| **Gemini 2.0 Flash** | ~$0.10 / $0.40 | 1M | Staying inside the free tier, lowest cost |

The common pattern: run Gemini 3 Flash by default and override to 3.1 Pro only when a task actually needs the extra reasoning. The reason to bother with Gemini at all is that 1M-token window — you can feed it a small monorepo or a pile of logs in one prompt. For the full breakdown, see [Best Gemini Model for OpenClaw](/blog/best-gemini-models-for-openclaw/).

## Common problems

- **401 / invalid key.** You copied a project ID or OAuth token instead of the AI Studio API key. Generate a fresh API key in AI Studio and paste that.
- **Hitting rate limits fast.** You're past the free tier, or sending huge 1M-token contexts on every turn — trim the files OpenClaw has loaded. The free tier counts requests, so fewer, leaner calls go further.
- **Model not found.** The model ID in your allowlist doesn't match Google's current naming. Check the exact ID in AI Studio and copy it verbatim.
- **Wrong base URL.** It should end at `/v1beta` — don't append a path. OpenClaw handles the rest.

## Set up haimaker.ai instead — one key, every model

If you don't want a separate Google account, or you're already routing other models, you can reach all the Gemini models through haimaker.ai with a single API key — alongside Claude, GPT, DeepSeek, Grok, MiniMax, and the rest.

1. Create an account and copy an API key at [app.haimaker.ai](https://app.haimaker.ai/sign-up?utm_source=openclaw_blog&utm_medium=cta&utm_campaign=gemini_api_key). New accounts start with free credits.
2. Add haimaker as a provider in `~/.openclaw/openclaw.json`:

   ```json
   {
     "models": {
       "providers": {
         "haimaker": {
           "baseUrl": "https://api.haimaker.ai/v1",
           "apiKey": "your-haimaker-api-key",
           "api": "openai-completions",
           "models": [
             { "id": "google/gemini-3-flash", "name": "Gemini 3 Flash" },
             { "id": "google/gemini-3-1-pro", "name": "Gemini 3.1 Pro" }
           ]
         }
       }
     }
   }
   ```

   Skip the editing altogether and let the CLI write that exact block: `npx -y @haimaker/connect --openclaw` adds the haimaker provider and registers the Gemini models for you, collapsing this step into one command. The [connect quickstart](/connect) explains the flags.

3. Start OpenClaw, run `/model`, and pick a Gemini model. To add other providers later — Claude, GPT, DeepSeek — just add their model IDs to the same `haimaker` block; the key and base URL don't change.

Want to compare Gemini against everything else on price and benchmarks first? They're all side by side at [haimaker.ai](https://haimaker.ai).

<a href="https://app.haimaker.ai/sign-up?utm_source=openclaw_blog&utm_medium=cta&utm_campaign=gemini_api_key" class="cta-button">GET $10 FREE CREDITS ON HAIMAKER</a>

---

*Related: [Best Gemini Model for OpenClaw](/blog/best-gemini-models-for-openclaw/) · [OpenClaw API Key Setup](/blog/openclaw-api-key-setup/) · [OpenClaw Custom Provider Setup](/blog/openclaw-custom-provider-setup/)*
