# AI Website Tag Generator (/docs/experiments/ai-website-tag-generator)



<Callout type="warning">
  This is an experimental Worker. Use it as a starting point for your own projects.
</Callout>

The AI Website Tag Generator experiment fetches any webpage, extracts its content, and uses [Workers AI](https://developers.cloudflare.com/workers-ai/) to generate topic tags. Built with Hono and TypeScript, it runs on Cloudflare's edge network-no external API keys required.

## Features [#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 [#api-reference]

### GET /tags [#get-tags]

Generate topic tags for any webpage.

<TypeTable
  type="{
  url: {
    description:
      &#x22;The webpage URL or hostname to tag. Use `http://` or `https://` for full URLs, or a bare hostname like `example.com`.&#x22;,
    type: &#x22;string&#x22;,
    required: true,
  },
}"
/>

#### Response [#response]

**`tags`** `string[]`

An array of topic tags generated from the page content.

#### Example Request [#example-request]

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

#### Example Response [#example-response]

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

#### Error Responses [#error-responses]

**`error`** `string`

Human-readable error message.

**`code`** `string`

Machine-readable error code.

**400 Bad Request** - Missing or invalid URL:

```json
{
  "error": "Missing or invalid query parameter: url",
  "code": "INVALID_URL"
}
```

**502 Bad Gateway** - Failed to fetch webpage or AI error:

```json
{
  "error": "Failed to fetch or generate tags",
  "code": "FETCH_OR_AI_ERROR"
}
```

## Use Cases [#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 [#limitations]

* **JavaScript-heavy sites** - Only static HTML is fetched; client-rendered content is not executed
* **Workers AI limits** - Subject to [Workers AI usage limits](https://developers.cloudflare.com/workers-ai/platform/limits/) by plan
* **Fetch and size limits** - Same constraints as other URL-based experiments (timeout, HTML size cap)

## Deployment [#deployment]

<Steps>
  <Step>
    ### Click the deploy button [#click-the-deploy-button]

    [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/ai-website-tag-generator)
  </Step>

  <Step>
    ### Deploy [#deploy]

    Enable the **Workers AI** binding (`AI`) in your Worker settings. The deploy button configures this automatically via `wrangler.json`. Requires a Cloudflare account with Workers AI enabled.
  </Step>

  <Step>
    ### Test your deployment [#test-your-deployment]

    ```bash
    curl "https://your-worker.workers.dev/tags?url=https://www.cloudflare.com"
    ```
  </Step>
</Steps>

## Local Development [#local-development]

```bash
cd apps/experiments/ai-website-tag-generator
npm install
npm run dev
```

Test locally:

```bash
curl "http://localhost:8787/tags?url=https://www.cloudflare.com"
```

## Cloudflare Features Used [#cloudflare-features-used]

* **[Workers](https://developers.cloudflare.com/workers/)** - Serverless execution environment
* **[Workers AI](https://developers.cloudflare.com/workers-ai/)** - Run LLMs on the edge with the `AI` binding
* **[Fetch API](https://developers.cloudflare.com/workers/runtime-apis/fetch/)** - HTTP client for fetching webpages

## Next Steps [#next-steps]

<Cards>
  <Card title="Workers AI Models" href="https://developers.cloudflare.com/workers-ai/models/">
    Explore other models available in Workers AI
  </Card>

  <Card title="AI Website Summary" href="/experiments/ai-website-summary">
    Summarize webpages with Workers AI
  </Card>

  <Card title="GitHub Repository" href="https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/ai-website-tag-generator">
    View the complete source code
  </Card>

  <Card title="More Experiments" href="/">
    Explore other Cloudflare experiments
  </Card>
</Cards>
