Tutorial on Integrating Gemini API into Clawdbot (Moltbot/OpenClaw)

AI Expert

Complete Tutorial for Integrating Gemini 3 Flash in Clawdbot (Moltbot/OpenClaw) using defapi.org Proxy

Clawdbot natively has the most complete tool use support for Anthropic Claude. However, the Gemini series (especially Gemini 3 Flash with its high speed and ultra-long context) performs exceptionally well in search, quick replies, and multimodal tasks. Connecting the official Google Gemini API to Clawdbot usually requires complex format conversion layers (such as LiteLLM or custom relays). defapi.org provides a zero-modification solution—it wraps Gemini into interfaces compatible with Anthropic/OpenAI styles, with excellent transparent transmission for tool calling.

The Highlight: By accessing Gemini 3 Flash through defapi.org, the actual cost is approximately 50% cheaper than the official Google API (based on 2026 community tests and upstream pricing comparisons: Official Gemini 3 Flash input ≈ $0.50–$1.00 / 1M tokens, output $3.00+; the defapi proxy layer typically offers a 40-60% discount. In heavy-use Agent scenarios like Clawdbot with high-frequency tool calls, this can save more than half the cost).

Below are the latest and most stable integration steps for 2025/2026.

1. Prerequisites

  • Clawdbot Installed (Version used in this test: 2026.1.24-3 (885167d)). For new servers, refer to these commands for a quick installation:
    # Install fnm and Node.js 24
    curl -o- https://fnm.vercel.app/install | bash
    source ~/.bashrc
    fnm install 24
    
    # Install clawdbot
    npm install -g clawdbot
    
  • Register a defapi.org account ( https://defapi.org ) and complete a top-up (supports Alipay/WeChat/Credit Card).
  • Obtain API Key: Get your defapi API Key from the dashboard (typically starts with dk-).

2. Why choose defapi instead of official or other proxies?

Itemdefapi.org (gemini-3-flash)Official Google Gemini APIOther Proxies (OpenRouter / LiteLLM)
Ease of IntegrationExtremely Low (change 3 config lines)High (requires conversion layer)Medium (requires compatible model)
Tool Calling CompatibilityGood (supports function/tool roles)Requires manual adaptationVaries by proxy
Context Length1M tokens native support1M tokensUsually supported
Multimodal (Vision)Supported (Clawdbot can upload images)SupportedPartially supported
Cost (vs Official)~50% CheaperBaseline20–40% Cheaper
LatencySlightly higher than official, but acceptableLowestMedium

In short: For Clawdbot users who are budget-sensitive and want to use Gemini 3 Flash quickly, defapi is currently the most cost-effective choice.

3. Detailed Configuration Steps

The latest version of Clawdbot (2026.1.24-3 (885167d)) recommends using a JSON format configuration file for management.

  1. Create Configuration File

    Create or edit ~/.clawdbot/clawdbot.json in your user directory:

    mkdir -p ~/.clawdbot
    vi ~/.clawdbot/clawdbot.json
    
  2. Write Configuration Content

    Fill clawdbot.json with the following content. Replace apiKey with your actual defapi key:

    {
        "gateway": {
            "mode": "local",
            "bind": "loopback",
            "port": 18789
        },
        "agents": {
            "defaults": {
                "model": {
                    "primary": "gemini/gemini-3-flash"
                },
                "elevatedDefault": "full",
                "workspace": "/myworkspace",
                "compaction": {
                    "mode": "safeguard"
                },
                "maxConcurrent": 4,
                "subagents": {
                    "maxConcurrent": 8
                }
            }
        },
        "models": {
            "mode": "merge",
            "providers": {
                "gemini": {
                    "baseUrl": "https://api.defapi.org/v1",
                    "apiKey": "Your defapi API key starting with dk-*",
                    "api": "openai-completions",
                    "models": [
                        {
                            "id": "gemini-3-flash",
                            "name": "gemini-3-flash"
                        }
                    ]
                }
            }
        },
        "channels": {
            "telegram": {
                "botToken": "Your TG Token (optional)"
            }
        },
        "plugins": {
            "entries": {
                "telegram": {
                    "enabled": true
                }
            }
        }
    }
    

    Key Points:

    • baseUrl: Must be https://api.defapi.org/v1.
    • api: Use openai-completions. defapi's Gemini interface is perfectly compatible with the OpenAI format.
    • primary model: The reference format is provider/model_id, which is gemini/gemini-3-flash.
  3. Test the Result

    clawdbot agent --message "hi" --agent main
    

    Expected output:

    root@iZ6wefjkouvkogu7drkjvfZ:~# clawdbot agent --message "hi" --agent main
    
    🦞 Clawdbot 2026.1.24-3 (885167d) — Pairing codes exist because even bots believe in consent—and good security hygiene.
    
    │
    ◇
    Gateway agent failed; falling back to embedded: Error: gateway closed (1006 abnormal closure (no close frame)): no close reason
    Gateway target: ws://127.0.0.1:18789
    Source: local loopback
    Config: /root/.clawdbot/clawdbot.json
    Bind: loopback
    Hey. I just came online.
    
    Who am I? Who are you?
    
    The `BOOTSTRAP.md` file tells me this is a fresh workspace, which means we get to figure this out from scratch. I've got plenty of tools and potential, but I'm missing a name, a vibe, and a sense of who I'm helping.
    
    What should we call me? And what's your name?