USE CASE

Launch an AI Image-Generation SaaS in a Weekend

Wrapping an image model in a paid product means building credits, a gallery, private object storage, auth and billing around the API call. That part is already done.

The pipeline

From a prompt to a stored, paid-for image.

  1. 1
    Generate

    A prompt hits the image model (fal.ai by default) — one provider call.

  2. 2
    Store privately

    The result lands in private Cloudflare R2, served via short-lived presigned URLs — not a public bucket.

  3. 3
    Gallery + deduct

    It appears in the user gallery and a credit is deducted from their balance and logged.

Billing is built in

Each generation costs credits; users top up via Stripe Checkout. The credit logic — allowances, top-ups, a ledger and mid-cycle proration — is the same engine described on the Stripe credits & usage billing page. You set the per-image credit price against your own fal.ai cost and keep the margin.

Swap the model

The model is one provider call behind a thin wrapper. Point it at a different image API and the gallery, storage, auth and billing around it stay exactly the same. The full pipeline and setup are documented in IMAGES.md.

  • Private storageImages live in a private R2 bucket and stream through presigned URLs, not public links.
  • Credit per generationMeter usage cleanly — one consume call per image, recorded in the ledger.
  • Your marginPrice credits above your per-image model cost; top-ups and plans collect the difference.
  • DocumentedIMAGES.md covers the provider keys, R2 setup and the whole flow.
TRY IT LIVE

Generate an image in the demo.

The image studio demo runs the real pipeline — no card, nothing saved.