Tutorial on Integrating Gemini API into Clawdbot (Moltbot/OpenClaw)
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?
| Item | defapi.org (gemini-3-flash) | Official Google Gemini API | Other Proxies (OpenRouter / LiteLLM) |
|---|---|---|---|
| Ease of Integration | Extremely Low (change 3 config lines) | High (requires conversion layer) | Medium (requires compatible model) |
| Tool Calling Compatibility | Good (supports function/tool roles) | Requires manual adaptation | Varies by proxy |
| Context Length | 1M tokens native support | 1M tokens | Usually supported |
| Multimodal (Vision) | Supported (Clawdbot can upload images) | Supported | Partially supported |
| Cost (vs Official) | ~50% Cheaper | Baseline | 20–40% Cheaper |
| Latency | Slightly higher than official, but acceptable | Lowest | Medium |
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.
-
Create Configuration File
Create or edit
~/.clawdbot/clawdbot.jsonin your user directory:mkdir -p ~/.clawdbot vi ~/.clawdbot/clawdbot.json -
Write Configuration Content
Fill
clawdbot.jsonwith the following content. ReplaceapiKeywith 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 isgemini/gemini-3-flash.
- baseUrl: Must be
-
Test the Result
clawdbot agent --message "hi" --agent mainExpected 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?