MyPhotoAI · pSEO case study

How to give every pSEO leaf its own image, at zero unit cost

A pSEO surface where every leaf carries the same hero image looks templated to a reader and to a crawler. A surface where every leaf has its own on-topic image looks like editorial work. The hard part is getting there without a per-image cost that scales linearly with the slug list. This leaf documents the pipeline MyPhotoAI uses to make per-slug imagery free at unit cost and bounded at scale, with the actual numbers we have observed.

By AlkenaCode engineering team

We ship programmatic SEO surfaces, AI-driven receptionists, and case-study sites for Kenyan SMEs and overseas clients. Every claim on this page traces back to shipping work, not speculation. The audit tool on /audit is the same software we use to evaluate prospective engagements.

Authors of the myphotoai.alkenacode.dev pSEO surface itself. Source code is open at github.com/Kiragu-Maina/alkenacode-family. Production deployments include agents.alkenacode.dev and home.alkenacode.dev.

Last updated:

The hero image on this leaf was produced by the same script described in the body. The pipeline has shipped two production pSEO surfaces, agents.alkenacode.dev (eight images) and this one (twenty-two images), with one Pollinations failure across thirty generations.

How to give every pSEO leaf its own image, at zero unit cost

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.

packages/pseo/src/gen-images.tsts
for (const item of inputs.items) {
  const id = item.imageId ?? `${item.slug}-0`;
  const cdnUrl = `${inputs.cdnBase}/${inputs.cdnSubpath}/${item.slug}/${id}.webp`;
  if (await head200(cdnUrl)) {
    console.log(`skip ${item.slug}/${id} (already on CDN)`);
    continue;
  }
  try {
    const png = await generateOne(item.imagePrompt + inputs.styleSuffix);
    const webp = await sharp(png).webp({ quality: 85 }).withMetadata({}).toBuffer();
    const outDir = path.join(tmp, inputs.cdnSubpath, item.slug);
    await fs.mkdir(outDir, { recursive: true });
    await fs.writeFile(path.join(outDir, `${id}.webp`), webp);
  } catch (err) {
    failed.push(`${item.slug}/${id}`);
  }
}
await rsync(tmp, inputs.rsyncTarget);
return { failed };
The per-slug image-generation loop. HEAD-checks the CDN first so re-runs are idempotent; falls through to provider + sharp + write only when an image is missing.

Sources

Every claim on this page traces back to one of the verifiable sources below. Citations are publisher-stable; we avoid blog posts and other URLs that may not survive a year.

  1. Pollinations.ai: free generative image API (Pollinations)
  2. sharp: high-performance Node.js image processing (sharp)
  3. MDN: Cache-Control header (MDN)
  4. MDN: HTTP caching (MDN)
  5. RFC 9111: HTTP caching (IETF)
  6. Cloudflare docs: how the cache works (Cloudflare)
  7. web.dev: serving responsive images (web.dev)
  8. MDN: img srcset attribute (MDN)
  9. Google: page experience signals (Google Search Central)
  10. web.dev: Largest Contentful Paint (LCP) (web.dev)
Free site auditor

See how the pattern applies to your site

The auditor uses the same evidence bundle described above (robots, sitemap, page samples) and returns a structured opinion. No signup, no email required to see results.