Skip to main content
This is an experimental Worker. Use it as a starting point for your own projects.
The AI Website Tag Generator experiment fetches any webpage, extracts its content, and uses Workers AI to generate topic tags. Built with Hono and TypeScript, it runs on Cloudflare’s edge network—no external API keys required.

Features

  • Fetch and parse any public webpage
  • Extract title and body text from HTML
  • Generate topic tags using Workers AI (e.g. Llama 3.1)
  • Sub-second responses on the edge
  • Accepts full URLs or hostnames (e.g. https://cloudflare.com or example.com)

API Reference

GET /tags

Generate topic tags for any webpage.
url
string
required
The webpage URL or hostname to tag. Use http:// or https:// for full URLs, or a bare hostname like example.com.

Response

tags
string[]
An array of topic tags generated from the page content.

Example Request

curl "https://your-worker.workers.dev/tags?url=https://www.cloudflare.com"

Example Response

{
  "tags": ["technology", "CDN", "security", "edge computing", "DDoS protection"]
}

Error Responses

error
string
Human-readable error message.
code
string
Machine-readable error code.
400 Bad Request — Missing or invalid URL:
{
  "error": "Missing or invalid query parameter: url",
  "code": "INVALID_URL"
}
502 Bad Gateway — Failed to fetch webpage or AI error:
{
  "error": "Failed to fetch or generate tags",
  "code": "FETCH_OR_AI_ERROR"
}

Deployment

1

Clone and install dependencies

git clone https://github.com/shrinathsnayak/cloudflare-experiments
cd cloudflare-experiments/experiments/ai-website-tag-generator
npm install
2

Test locally

npm run dev
Then open: http://localhost:8787/tags?url=https://cloudflare.com
3

Deploy to Cloudflare Workers

npm run deploy
Requires a Cloudflare account with Workers AI enabled.

One-Click Deploy

Deploy to Cloudflare Workers Click the button above to deploy this Worker directly to your Cloudflare account. Fork the repository and update the URL to deploy from your own fork.

Cloudflare Features Used

  • Workers — Serverless execution environment
  • Workers AI — Run LLMs on the edge with the AI binding
  • Fetch API — HTTP client for fetching webpages

Use Cases

  • Content tagging — Auto-tag articles or bookmarks by topic
  • SEO and discovery — Suggest categories or related topics from page content
  • Link previews — Enrich shared links with topic tags
  • Research and curation — Quickly label pages by theme

Limitations

  • JavaScript-heavy sites — Only static HTML is fetched; client-rendered content is not executed
  • Workers AI limits — Subject to Workers AI usage limits by plan
  • Fetch and size limits — Same constraints as other URL-based experiments (timeout, HTML size cap)

Next Steps