Cloud & AI

Build & Deploy Your Own LLM Chatbot with Cloudflare Workers AI

Use the official llm-chat-app-template to create a private, blazing-fast AI chatbot in minutes — completely free with Cloudflare's generous limits.

Updated July 2026
12 min read
Beginner-Friendly

Why Build with Cloudflare?

Step-by-Step Guide

1

Prerequisites

  • Cloudflare account (free)
  • Node.js 18+ installed
  • Wrangler CLI
2

Create the Project

npm create cloudflare@latest -- --template cloudflare/llm-chat-app-template my-ai-chatbot

Or clone the repo directly:

git clone https://github.com/cloudflare/templates.git
cd templates/llm-chat-app
npm install
3

Install Dependencies & Generate Types

cd my-ai-chatbot
npm install
npm run cf-typegen
4

Run Locally

npm run dev

Open http://localhost:8787 to test your chatbot locally.

5

Deploy to Cloudflare

npm run deploy

After deployment, you'll get a URL like https://my-ai-chatbot.yourusername.workers.dev

Customize the Model

Edit wrangler.toml or the worker code to change the model (e.g., @cf/meta/llama-3.1-8b-instruct).

Embed the Chatbot as an iFrame Widget

After deployment, you can embed your chatbot on any website using an iframe.

Example HTML Embed Code:

<iframe src="https://YOUR-CHATBOT.workers.dev" width="400" height="650" style="border: none; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);" allow="clipboard-write"> </iframe>

Place this code anywhere in your HTML page. Adjust width/height as needed.

Pro Tips

  • • Use @cf/meta/llama-3.1-8b-instruct for great performance
  • • Add custom system prompts in the worker code
  • • Enable streaming for better UX
  • • Monitor usage in the Cloudflare dashboard
Start Building Now