---
title: &quot;Use Gemini in OpenClaw via RunAPI — LLM API Guide&quot;
url: &quot;https://runapi.ai/openclaw-gemini.md&quot;
canonical: &quot;https://runapi.ai/openclaw-gemini&quot;
locale: &quot;en&quot;
model: &quot;gemini&quot;
---

# Use Gemini in OpenClaw.

Google Gemini is available through RunAPI&#39;s OpenAI-compatible endpoint — Gemini 3.5 Flash for sub-100ms first-token latency, 3.x Pro for complex reasoning, and 2.5 Pro for production workloads. OpenClaw treats it as another OpenAI-compatible model, so the same provider config and RUNAPI_API_KEY that powers GPT also calls Gemini. No Google Cloud project, no service account, no Vertex AI setup.

## API example

```bash
curl -X POST https://runapi.ai/v1/chat/completions \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;gemini-3.5-flash&quot;,
    &quot;messages&quot;: [
      {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a concise technical assistant.&quot;},
      {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Explain the difference between gRPC and REST in three sentences.&quot;}
    ],
    &quot;temperature&quot;: 0.7,
    &quot;max_tokens&quot;: 256
  }&#39;

```

### Response

```json
{
  &quot;id&quot;: &quot;chatcmpl-abc123&quot;,
  &quot;object&quot;: &quot;chat.completion&quot;,
  &quot;model&quot;: &quot;gemini-3.5-flash&quot;,
  &quot;choices&quot;: [
    {
      &quot;index&quot;: 0,
      &quot;message&quot;: {
        &quot;role&quot;: &quot;assistant&quot;,
        &quot;content&quot;: &quot;gRPC uses HTTP/2 and Protocol Buffers for strongly-typed, multiplexed RPC calls with built-in code generation. REST uses HTTP/1.1 (or 2) with JSON payloads and relies on URL paths and HTTP verbs for resource semantics. gRPC is faster for service-to-service calls; REST is simpler to debug and more widely supported by browsers.&quot;
      },
      &quot;finish_reason&quot;: &quot;stop&quot;
    }
  ],
  &quot;usage&quot;: {
    &quot;prompt_tokens&quot;: 34,
    &quot;completion_tokens&quot;: 71,
    &quot;total_tokens&quot;: 105
  }
}

```

## How it works

1. **Configure RunAPI** — Set the RUNAPI_API_KEY environment variable. If you already configured RunAPI as an OpenClaw provider, the same key and baseUrl work for Gemini — just change the model ID. No Google Cloud credentials needed.
2. **Call Gemini via chat completions** — Send a POST request to /v1/chat/completions with model set to gemini-3.5-flash. Pass a messages array with system and user roles. The endpoint accepts the same OpenAI-compatible shape your agent already uses for GPT models.
3. **Read the response** — The response arrives synchronously in OpenAI chat completion format. The assistant reply is in choices[0].message.content, with token usage in the usage object. For streaming, set stream to true and parse SSE events.

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | Required. gemini-3.5-flash, gemini-2.5-flash, gemini-2.5-pro, gemini-3-flash-preview, gemini-3-pro-preview, or gemini-3.1-pro-preview. |
| `messages` | `array` | Required. Array of message objects with role (system, user, assistant) and content fields. |
| `temperature` | `number` | Optional. Sampling temperature between 0 and 2. Lower values produce more deterministic output. Default varies by model. |
| `max_tokens` | `integer` | Optional. Maximum number of tokens to generate in the response. |
| `stream` | `boolean` | Optional. When true, the response streams as server-sent events. Each event contains a delta with partial content. |
| `top_p` | `number` | Optional. Nucleus sampling threshold between 0 and 1. Alternative to temperature for controlling output randomness. |

## FAQ

### Can I use Google Gemini in OpenClaw without a Google Cloud project?

Yes. RunAPI provides Gemini access through its OpenAI-compatible endpoint. You only need a RUNAPI_API_KEY -- no Google Cloud project, no service account JSON, no Vertex AI billing setup.

### What is the difference between Gemini Flash vs Pro -- when should I use each?

Flash (gemini-3.5-flash) is fastest and cheapest -- best for real-time agent loops, classification, and tool-calling chains. Pro (gemini-2.5-pro) handles complex reasoning, long-context analysis, and multi-step tasks where accuracy matters more than speed.

### Is the Gemini API still free through RunAPI?

RunAPI uses pay-per-token billing for Gemini with no free tier. However, Gemini Flash rates are among the lowest in the RunAPI catalog. Input and output tokens are metered separately. Check the RunAPI pricing page for current rates.

### Can I switch between Gemini and GPT in the same OpenClaw session?

Yes. Both use the same RunAPI provider config and API key. Change the model parameter from gemini-3.5-flash to gpt-5.5 (or any other RunAPI model) without reconfiguring the provider. OpenClaw selects models per request.

### Does Gemini through RunAPI support function calling and tool use?

Yes. RunAPI passes the OpenAI-compatible tools and tool_choice parameters to Gemini. Define tools in the request body and Gemini returns tool_calls in the assistant message. OpenClaw processes these the same way it handles tool calls from GPT or Claude.


## Links

- [OpenClaw setup guide →](https://runapi.ai/openclaw)
- [Gemini models →](https://runapi.ai/models/gemini)
- [Model catalog](https://runapi.ai/models)
- [API docs](https://runapi.ai/docs)
