I built a fully autonomous AI agent that costs $0/month to run. Here is exactly how.
When you build an AI agent, the first thing you reach for is an API: OpenAI, DeepSeek, Groq. They work great β until you check the bill. Even at $0.14/million tokens, a moderately active agent burns through $30-50/month. That is a GPU you will never save up for.
The second problem: most conversations do not need a frontier model. When a customer asks "How much is wedding photography?", you do not need GPT-5. You need a FAQ lookup + a friendly reply. Yet API pricing charges the same rate whether you are writing a novel or answering "What are your hours?"
I wanted something better. So I hacked together a stack that runs completely free:
Cloudflare Workers (free tier) β Gemini Web (free) β 24/7 AI Agent
Here is the architecture and how you can build your own.
Google Gemini's web interface at gemini.google.com
is free. No API key, no rate limits, no token counting. The model is powerful enough for 90% of customer service tasks.
The catch: it is a web page, not an API. But we can fix that.
Workers free tier gives you 100,000 requests/day. That is more than enough for a small business AI agent handling ~500 customer chats daily.
We use Chrome DevTools Protocol (CDP) to control a browser that talks to Gemini Web. A small Node.js proxy translates standard OpenAI-compatible API requests into browser actions.
Customer Message
β
Cloudflare Worker (/api/chat)
β
Node.js Proxy (:57322)
β
Chrome CDP β types into gemini.google.com
β
Extracts reply β returns as API response
This is the core β a server that accepts OpenAI-format requests and forwards them to Gemini Web via Playwright:
const { chromium } = require("playwright");
async function getGeminiReply(prompt) {
const browser = await chromium.connectOverCDP("http://127.0.0.1:9222");
const page = browser.contexts()[0].pages()
.find(p => p.url().includes("gemini"));
// Type and send
const tb = page.getByRole("textbox", { name: /enter a prompt/i }).first();
await tb.fill(prompt);
await page.getByRole("button", { name: /send message/i }).click();
// Wait for completion
for (let i = 0; i < 80; i++) {
await page.waitForTimeout(1000);
const hasStop = await page.evaluate(() =>
!!document.querySelector('[aria-label="Stop generating"]')
);
if (!hasStop) break;
}
// Extract and return
return await page.evaluate(() => {
const msgs = document.querySelectorAll("message-content");
return msgs[msgs.length - 1]?.innerText || "";
});
}
Not every question needs Gemini. FAQ matching handles 70% of queries instantly and for free:
const FAQ = [
{ keywords: ["δ»·ζ Ό", "ε€ε°ι±"], a: "εΊη‘ε₯ι€ Β₯1999 θ΅·..." },
{ keywords: ["ι’ηΊ¦", "ζ‘£ζ"], a: "ζε3-7倩ι’ηΊ¦ε³ε―..." },
{ keywords: ["ε°ε", "εͺι"], a: "ζ们ε¨ζι½ι¦ζ±εΊ..." }
];
function matchFAQ(message) {
for (const item of FAQ) {
if (item.keywords.some(k => message.includes(k))) {
return item.a; // Instant, no API call
}
}
return null; // Fall through to Gemini
}
The Worker also stores customer contacts in Cloudflare KV:
async function handleLead(request, env) {
const { name, contact, need } = await request.json();
await env.LEADS.put(crypto.randomUUID(), JSON.stringify({
name, contact, need,
created_at: new Date().toISOString()
}));
return Response.json({ ok: true });
}
I deployed this for a photography studio in 2 hours. Here is what happened:
| Metric | Before | After |
|---|---|---|
| Customer response time | 2-6 hours | Instant |
| Missed inquiries (overnight) | ~40% | 0% |
| Owner time spent on FAQs | 3h/day | 30min/day |
| Monthly cost | Β₯0 (owner's labor) | Β₯0 (fully free) |
The live demo is at: https://ihug-demo.wigginsbuck7.workers.dev/
The agent stack is now free:
Codex Desktop β Router (:57323) β < 4000 tokens β Gemini Web (FREE)
β β₯ 4000 tokens β DeepSeek API (paid, but rare)
Info Pipeline β GitHub API + Hacker News + Dev.to (all free)
Cloudflare KV β Lead storage (free tier)
Chrome CDP β Browser automation (free)
Total monthly spend: Β₯0 (plus ~Β₯15 for DeepSeek on long replies, maybe Β₯30/month).
--remote-debugging-port=9222
The entire setup takes one afternoon. After that, it runs indefinitely at zero cost.
If you found this useful, the demo is live at ihug-demo.wigginsbuck7.workers.dev. Drop a test inquiry β an AI will answer you, and it costs me nothing.