This repository contains a simple Cloudflare Worker script that generates images based on a text prompt using the DreamShaper model from the Cloudflare AI service.
- 🎨 Generates images based on text prompts
- 🖼️ Returns the generated image in PNG format
⚠️ Handles errors gracefully
-
Clone the repository:
git clone https://github.com/cnncodex/ai-image-generator.git cd ai-image-generator
-
Install Cloudflare Workers CLI (Wrangler):
npm install -g wrangler
- Create a Cloudflare account and set up a new Worker.
- Set up your environment variables in the Cloudflare dashboard.
-
Authenticate Wrangler with your Cloudflare account:
wrangler login
-
Publish your Worker:
wrangler publish
To generate an image, send a GET request to your deployed Worker's URL with the prompt
query parameter.
Example:
curl "https://your-worker-url.workers.dev/?prompt=A beautiful sunset over the mountains"