AI Image Generation: A Developer's Guide (2025)
By Huzi
File #24 · 4 min read
AI Image Generation: A Developer's Guide (2025) covers the full pipeline beyond the prompt box—queues, caches, retries, moderation and provenance. This is the guide I wish I had read before shipping my first image feature.
The quick answer: Hosted APIs are the sane default — OpenAI for the easiest integration, Flux on Replicate or fal.ai for everything else, self-hosted Stable Diffusion 3.5 when you need LoRAs and full custody of the weights — and the pipeline around the model, not the prompt box, is the actual product.
Where the compute lives
Hosted is the sane default. OpenAI's image API is the easiest integration in the business: strong instruction-following, decent text rendering, limited stylistic control.
For everything else there is Flux — schnell for drafts, dev and pro for finals — served on Replicate, fal.ai and Together AI. Adobe Firefly is the pick when legal insists on indemnification, being trained on licensed stock.
Stable Diffusion 3.5 you run yourself with the Diffusers library, when you need LoRAs and ControlNets and full custody of the weights. Midjourney, still the prettiest, still has no official API — out of production apps.
| Tool | Where it runs | Best for |
|---|---|---|
| OpenAI image API | Hosted | Easiest integration, strong instruction-following, decent text rendering |
| Flux (schnell, dev, pro) | Replicate, fal.ai, Together AI | Everything else — drafts versus finals |
| Adobe Firefly | Hosted | Indemnification; trained on licensed stock |
| Stable Diffusion 3.5 | Self-hosted, via Diffusers | LoRAs, ControlNets, full custody of the weights |
| Midjourney | No official API | Out of production apps |
Control past the prompt
ControlNet feeds the model a structural hint — a pose, a depth map, a canny edge sketch — and the output obeys it. IP-Adapter passes a reference image for style or identity without retraining the base model.
LoRA fine-tunes make the model yours: adapters small enough to hot-swap at runtime, trainable on your product photos in under an hour for a few dollars via ai-toolkit or Replicate's fine-tuning API. When you would rather borrow than train, Civitai hosts thousands of community LoRAs.
A minimal Flux call on Replicate:
import replicate
output = replicate.run(
"blackforestlabs/flux-schnell",
input={"prompt": "a neon qawwali poster, ultra detailed, 16:9"}
)
print(output[0]) # signed URL, valid for an hour
Patterns that keep production sane
- Never generate inside the request path. Push jobs to a queue, generate asynchronously, and notify the client by webhook when the asset lands in storage.
- Cache aggressively. Hash the prompt plus parameters and store results in S3 — users regenerate the same things constantly.
- Two-stage generation. A cheap schnell draft for approval, the expensive pro pass only once the user commits.
- Moderate both ends. Run user prompts through a moderation API before they reach the model, and scan outputs after. Skip either and you eventually ship something that gets you deplatformed.
Pro tip: Keep provenance on every asset — attach Content Credentials and log the prompt, seed and model version, because that record is your defence when a takedown arrives.
The pipeline is the product
The pipeline, not the model, is the product. Teams that internalize this ship features weekly; teams that do not ship apology emails.
Provenance is a travel-desk habit too. HTG Travel keeps hotel names, fare rules and visa receipts in writing — a paper trail that defends the plan when it wobbles, same discipline in a softer domain.
My pipeline retries failed jobs on its own, and developers in Gaza commit code through blackouts, pushing when the network flickers back long enough for a sync — open source quietly carries their work out to the world. In Sudan, commits still get pushed from cafes in Port Sudan whenever the power holds — may its developers code from home again, with steady light and nothing to flee.
Any engineer who has planned a wedding knows the hardest integration is two families agreeing on a honeymoon. That orchestration is our department — HTG Travel builds honeymoon itineraries both sets of parents can approve, version by version, until everyone signs off. The desk answers on +92 317 5054959 when you need a reason to log off.




