gpt-puppeteer
v1.0.0
Published
A Cloudflare Worker that uses Puppeteer to automate image generation with ChatGPT.
Readme
GPT Puppeteer
A Cloudflare Worker that uses Puppeteer to automate image generation with ChatGPT.
Features
- HTTP API for submitting image generation requests
- Queue-based processing for reliability
- Support for uploading images or providing image URLs
- Webhook notifications when images are ready
- Local development with a real Chrome browser
Setup
Prerequisites
- Node.js 18+
- pnpm or npm
- Cloudflare account with Workers and R2 enabled
Installation
# Install dependencies
pnpm installLocal Development
- Create a
cookies.jsonfile with your ChatGPT cookies (seecookies.json.example) - Start the local development server:
pnpm dev:workerThis will launch a local server at http://localhost:8787 and use your local Chrome browser for processing.
Production Setup
- Set up the required Cloudflare resources:
# Create R2 buckets and queue
pnpm setup:all
# Or individually:
pnpm setup:buckets
pnpm setup:queue- Upload your cookies to R2:
pnpm cookies:upload- Deploy the worker:
pnpm publishUsage
Submitting a Job
curl -X POST https://your-worker.workers.dev \
-F "prompt=A beautiful sunset over mountains" \
-F "webhook_url=https://your-webhook.com/callback"You can also include an image:
curl -X POST https://your-worker.workers.dev \
-F "prompt=Make this image more vibrant" \
-F "[email protected]"Or an image URL:
curl -X POST https://your-worker.workers.dev \
-F "prompt=Make this image more vibrant" \
-F "image_url=https://example.com/image.jpg"Checking Job Status
curl https://your-worker.workers.dev/JOB_IDCookie Management
Downloading Cookies from Production
pnpm cookies:downloadUploading Cookies to Production
pnpm cookies:uploadLocal Cookie Configuration
You can either:
- Create a
cookies.jsonfile in the project root - Add your cookies to the
.envfile asCHATGPT_COOKIES
Development Commands
pnpm build: Build the TypeScript codepnpm dev:worker: Run the worker locally with a real Chrome browserpnpm dev:worker:remote: Run the worker on Cloudflare's edge (temporary deployment)pnpm deploy: Deploy the worker to productionpnpm publish: Build and deploy the worker to productionpnpm cookies:upload: Upload local cookies.json to R2pnpm cookies:download: Download cookies.json from R2pnpm setup:buckets: Create R2 bucketspnpm setup:queue: Create Cloudflare Queuepnpm setup:all: Set up all required Cloudflare resources
