How I built an AI headshot generator in 30 seconds (FLUX + Next.js + Stripe)
Source: Dev.to
Overview
I had a weekend free and a simple question: how cheap and fast can I get a professional headshot delivered to someone?
The answer I landed on: 30 seconds, £4.99. Below is the architecture and flow I built to achieve this.
Tech Stack
| Component | Service |
|---|---|
| Front‑end & routing | Next.js 14 (App Router) deployed on Netlify |
| Image generation | fal.ai – FLUX AI model |
| Payments | Stripe – one‑time Checkout (no subscriptions) |
| Temporary storage | Vercel Blob |
| Cost per headshot | ≈ £0.04 (infrastructure only) |
Workflow
- Upload – User uploads any clear face photo.
- Store temporarily – The image is saved in Vercel Blob, which returns a public URL.
- Select plan – User chooses either a single headshot (£4.99) or a 5‑pack (£14.99).
- Checkout – Redirect to Stripe Checkout.
- Success callback – After payment, Stripe redirects back with the photo URL and plan metadata via the success URL.
- Generate –
fal.ai(FLUX /dev model) creates the professional headshot(s) using the supplied URL and the plan’s instructions. - Download – The generated image is returned instantly for the user to download.
The entire flow is stateless: no database, no user accounts, and no long‑term storage of photos beyond the generation window.
Getting Consistent Professional Results
The key to reliable headshots was adding explicit prompts:
- Lighting – e.g., “soft, even lighting”.
- Background colour – e.g., “plain white background”.
- Attire context – e.g., “business casual”.
- Use‑case anchor – e.g., “LinkedIn profile photo”.
Without these cues, the model defaults to a generic portrait.
Performance Comparison
| Provider | Avg. generation time |
|---|---|
| fal.ai (FLUX /dev) | 8–12 s |
| Replicate (same model) | 18–25 s |
fal.ai proved consistently faster, and its SDK felt cleaner to integrate.
Stripe Integration Details
- Used dynamic
price_datainstead of pre‑created Stripe Price objects. - Keeps pricing logic in code, eliminating the need for dashboard configuration.
- After checkout, retrieve the session by its ID to obtain the metadata (photo URL, selected plan).
Pricing & Live Demo
The service is intentionally priced lower than competitors (most charge £15–£50 for comparable quality).
Live demo:
Feel free to try it out and ask any questions in the comments.