cd /news/ai-agents/zero-cost-ai-agent-stack-cloudflare-… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-23235] src=dev.to pub= topic=ai-agents verified=true sentiment=↑ positive

Zero-Cost AI Agent Stack: Cloudflare Workers + Gemini Web = 24/7 Free AI

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.

read3 min publishedJun 6, 2026

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.

── more in #ai-agents 4 stories Β· sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/zero-cost-ai-agent-s…] indexed:0 read:3min 2026-06-06 Β· β€”