Free tier first, paid tier never
Pollinations.ai is the default provider. It is free, rate-limited to roughly one request per fifteen seconds, and the output quality at the flux model is acceptable for pSEO surfaces where the image is supporting rather than the headline. The script supports a paid flag for higher fidelity when a specific surface needs it, but the default path on our 22-leaf set costs nothing and produced acceptable results in a single overnight run. For a hundred-leaf surface, the cost remains zero; for a thousand-leaf surface, the rate limit imposes a four-hour wall time, still at zero dollars.
Idempotent by filename, deterministic on disk
Each slug emits an image at a deterministic CDN path: /pseo/{slug}/{slug}-0.webp. Before generating, the script issues an HTTP HEAD against the public URL. If the image already exists, the slug is skipped. Re-running the generator on a manifest with no slug changes costs zero requests and a few seconds of HEAD-check time across the whole set. This is also how we recover from partial failures: if one of twenty-two slugs failed network mid-run, we re-run the entire script and only the failed slug regenerates.
Optimize on the way out, immutable at the edge
Generated PNGs run through sharp: convert to WEBP, quality 85, strip EXIF, no resize beyond the source. Output sizes land between forty and ninety kilobytes for the twelve-hundred by six-seventy-five output. The CDN serves the resulting files with Cache-Control: public, max-age=2592000, immutable; cache hit rates at the edge are effectively 100% after the initial fill. The pipeline writes to /var/www/images.alkenacode.dev/pseo/ on the same host that serves the leaves, fronted by Cloudflare.
