{"slug": "zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai", "title": "Zero-Cost AI Agent Stack: Cloudflare Workers + Gemini Web = 24/7 Free AI", "summary": "A developer built a fully autonomous AI agent that runs at zero monthly cost by combining Cloudflare Workers' free tier with Google Gemini's free web interface. The stack uses Chrome DevTools Protocol to control a browser that interacts with gemini.google.com, translating standard OpenAI-compatible API requests into browser actions. For a photography studio deployment, the agent reduced customer response time from 2-6 hours to instant, eliminated overnight missed inquiries, and cut owner time spent on FAQs from 3 hours to 30 minutes daily.", "body_md": "*I built a fully autonomous AI agent that costs $0/month to run. Here is exactly how.*\n\nWhen 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.\n\nThe 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?\"\n\nI wanted something better. So I hacked together a stack that runs **completely free**:\n\n```\nCloudflare Workers (free tier) → Gemini Web (free) → 24/7 AI Agent\n```\n\nHere is the architecture and how you can build your own.\n\nGoogle Gemini's web interface at `gemini.google.com`\n\nis free. No API key, no rate limits, no token counting. The model is powerful enough for 90% of customer service tasks.\n\nThe catch: it is a web page, not an API. But we can fix that.\n\nWorkers free tier gives you 100,000 requests/day. That is more than enough for a small business AI agent handling ~500 customer chats daily.\n\nWe 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.\n\n```\nCustomer Message\n    ↓\nCloudflare Worker (/api/chat)\n    ↓\nNode.js Proxy (:57322)\n    ↓\nChrome CDP → types into gemini.google.com\n    ↓\nExtracts reply → returns as API response\n```\n\nThis is the core — a server that accepts OpenAI-format requests and forwards them to Gemini Web via Playwright:\n\n``` js\nconst { chromium } = require(\"playwright\");\n\nasync function getGeminiReply(prompt) {\n  const browser = await chromium.connectOverCDP(\"http://127.0.0.1:9222\");\n  const page = browser.contexts()[0].pages()\n    .find(p => p.url().includes(\"gemini\"));\n\n  // Type and send\n  const tb = page.getByRole(\"textbox\", { name: /enter a prompt/i }).first();\n  await tb.fill(prompt);\n  await page.getByRole(\"button\", { name: /send message/i }).click();\n\n  // Wait for completion\n  for (let i = 0; i < 80; i++) {\n    await page.waitForTimeout(1000);\n    const hasStop = await page.evaluate(() =>\n      !!document.querySelector('[aria-label=\"Stop generating\"]')\n    );\n    if (!hasStop) break;\n  }\n\n  // Extract and return\n  return await page.evaluate(() => {\n    const msgs = document.querySelectorAll(\"message-content\");\n    return msgs[msgs.length - 1]?.innerText || \"\";\n  });\n}\n```\n\nNot every question needs Gemini. FAQ matching handles 70% of queries instantly and for free:\n\n``` js\nconst FAQ = [\n  { keywords: [\"价格\", \"多少钱\"], a: \"基础套餐 ¥1999 起...\" },\n  { keywords: [\"预约\", \"档期\"], a: \"提前3-7天预约即可...\" },\n  { keywords: [\"地址\", \"哪里\"], a: \"我们在成都锦江区...\" }\n];\n\nfunction matchFAQ(message) {\n  for (const item of FAQ) {\n    if (item.keywords.some(k => message.includes(k))) {\n      return item.a; // Instant, no API call\n    }\n  }\n  return null; // Fall through to Gemini\n}\n```\n\nThe Worker also stores customer contacts in Cloudflare KV:\n\n```\nasync function handleLead(request, env) {\n  const { name, contact, need } = await request.json();\n  await env.LEADS.put(crypto.randomUUID(), JSON.stringify({\n    name, contact, need,\n    created_at: new Date().toISOString()\n  }));\n  return Response.json({ ok: true });\n}\n```\n\nI deployed this for a photography studio in 2 hours. Here is what happened:\n\n| Metric | Before | After |\n|---|---|---|\n| Customer response time | 2-6 hours | Instant |\n| Missed inquiries (overnight) | ~40% | 0% |\n| Owner time spent on FAQs | 3h/day | 30min/day |\n| Monthly cost | ¥0 (owner's labor) | ¥0 (fully free) |\n\nThe **live demo** is at: `https://ihug-demo.wigginsbuck7.workers.dev/`\n\nThe agent stack is now free:\n\n```\nCodex Desktop → Router (:57323) → < 4000 tokens → Gemini Web (FREE)\n                                  → ≥ 4000 tokens → DeepSeek API (paid, but rare)\nInfo Pipeline → GitHub API + Hacker News + Dev.to (all free)\nCloudflare KV → Lead storage (free tier)\nChrome CDP → Browser automation (free)\n```\n\nTotal monthly spend: **¥0** (plus ~¥15 for DeepSeek on long replies, maybe ¥30/month).\n\n`--remote-debugging-port=9222`\n\nThe entire setup takes one afternoon. After that, it runs indefinitely at zero cost.\n\n*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.*", "url": "https://wpnews.pro/news/zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai", "canonical_source": "https://dev.to/justsosdsds/-zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-247-free-ai-2fke", "published_at": "2026-06-06 07:54:18+00:00", "updated_at": "2026-06-06 08:11:51.713105+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-infrastructure", "artificial-intelligence", "large-language-models"], "entities": ["Cloudflare Workers", "Gemini Web", "Google", "OpenAI", "DeepSeek", "Groq", "Chrome DevTools Protocol", "Node.js"], "alternates": {"html": "https://wpnews.pro/news/zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai", "markdown": "https://wpnews.pro/news/zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai.md", "text": "https://wpnews.pro/news/zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai.txt", "jsonld": "https://wpnews.pro/news/zero-cost-ai-agent-stack-cloudflare-workers-gemini-web-24-7-free-ai.jsonld"}}