惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
博客园_首页
WordPress大学
WordPress大学
罗磊的独立博客
小众软件
小众软件
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The Cloudflare Blog
GbyAI
GbyAI
C
Check Point Blog
腾讯CDC
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
博客园 - 聂微东
IT之家
IT之家
雷峰网
雷峰网
H
Help Net Security
博客园 - 叶小钗
美团技术团队
D
DataBreaches.Net

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I built Img2Gen, a GPT Image 2 studio on Cloudflare Workers
visiohex · 2026-06-05 · via DEV Community

visiohex

I recently built Img2Gen, a focused web studio for GPT Image 2 generation.

The idea was simple: I wanted something more practical than a single prompt box. For real creative work, I often need to try multiple aspect ratios, upload reference images, generate several variants, download the results, and keep a history of what worked.

So Img2Gen supports:

  • Text-to-image generation
  • Reference-image edits with up to 5 uploaded images
  • 1, 2, or 4 outputs per request
  • Multiple aspect ratios
  • Low, medium, and high quality modes
  • Daily free generations
  • Credit-based paid usage
  • Generation history and downloads
  • Automatic refunds when a generation fails

The Stack

The app is built with:

  • TanStack Start
  • React 19
  • Cloudflare Workers
  • Cloudflare D1 with Drizzle ORM
  • Cloudflare R2 for generated image storage
  • Better Auth
  • Stripe / Creem for payments
  • A server-side GPT Image 2 generation provider

I wanted the whole thing to run close to the edge, avoid a traditional server, and keep the architecture small enough that I could iterate quickly.

Why Cloudflare Workers?

Image generation itself is slow compared with a normal web request, so the main app has to handle queued jobs, polling, persistence, and failures cleanly.

The flow looks roughly like this:

  1. User submits a prompt and optional reference images
  2. The server validates the request and checks moderation
  3. Free daily usage or credits are reserved
  4. A generation job is submitted to the provider
  5. The client polls for status
  6. Successful images are downloaded, moderated, and persisted to R2
  7. The generation record is saved in D1
  8. Credits are refunded if the job fails

The hardest part was not the UI. It was making the generation workflow feel reliable when the underlying job can take a while or fail halfway through.

Credit Handling

I ended up using a credit model because image quality and output count change the cost.

Currently:

  • Low quality: 1 credit per image
  • Medium quality: 4 credits per image
  • High quality: 16 credits per image

Free users get daily generations, and paid users can use monthly credits or credit packs.

One small detail I cared about: failed generations should not silently burn credits. If a job fails after credits are reserved, the system refunds them automatically.

Reference Images

Reference-image editing was one of the main reasons I built this.

Img2Gen accepts PNG, JPG, and WebP references, up to 5 images per request. This makes it useful for product shots, ad creatives, portraits, style exploration, and iterative edits where you want the output to stay anchored to existing visuals.

What I Learned

A few takeaways from building it:

  • AI image apps need good job recovery, not just good prompts.
  • Credit systems need to be boring and predictable.
  • Storing generated outputs matters because provider URLs are not always a long-term product experience.
  • A focused workflow can be more useful than exposing every possible model setting.
  • Edge/serverless architectures work well here, but long-running generation flows need careful state design.

Try It

You can try it here:

https://img2gen.com

I would love feedback from other builders, especially on:

  • Whether the generation flow feels clear
  • Whether the credit model is understandable
  • What reference-image workflows you would expect from a tool like this
  • Any architecture suggestions for long-running AI generation jobs on serverless platforms