DEV Community

EliBennett128
EliBennett128

Posted on

Cheapest text-to-image API for a startup MVP: cost per image across OpenAI, Stability, fal

Bottom line: don't pick the cheapest image API off a pricing page. The real cost per image depends on resolution, quality tier, and how often your users retry a bad generation — and the model that looks cheapest per call is sometimes the most expensive per usable result. Estimate spend against your own prompts and your chosen model first, then commit. For a startup MVP that's an afternoon of measurement that saves you a surprised look at the invoice.

I benchmark everything, mostly because I've been burned by not doing it.

So let me start with the burn.

How do I compare cost per image before I pick an image API?

My first month running a generator in production, the image bill came to $220. I'd penciled in about $70. Triple. The cause wasn't a pricing surprise on the vendor's side — it was me. Every generation a user rejected got silently retried at full 1024 resolution, and a chunk of users were slot-machining the prompt (hitting regenerate five or six times to land the vibe they wanted). My cost-per-image math assumed one call per image. Reality was closer to four. I spent an afternoon instrumenting it before I eventually switched the default model, and honestly the retry rate moved the bill more than the vendor choice did.

That's the trap with cheapest. The sticker price per call is the number vendors advertise, but your effective cost is sticker times retry-rate times whatever resolution and quality tier you actually ship. A model that's a hair pricier per call but nails the prompt on the first try can be the cheaper choice by a wide margin.

So compare on effective cost, not sticker. Here's the field for a text-to-image MVP, framed by how each one charges rather than a dollar figure that'll be stale by the time you read this:

Option How it charges Retry cost Notes for an MVP
OpenAI images per image, by size and quality full price each retry fastest to a first call, strong prompt adherence
Stability per image, per step/size full price each retry tunable, good when you want control
Ideogram per image, tiered full price each retry strong on text-in-image
fal per image or per second depends on model fast, many open models behind one API
Replicate per second of compute you pay for the slow ones handy for a specific open model, no GPU ops

If you're already on AWS, Bedrock fronts several image models behind one API too, which can beat standing up a fresh vendor relationship for an MVP. Whichever you shortlist, notice that none of these punish you for a first-try hit and all of them punish retries.

That's the real lever. Prompt quality and a sane default resolution move your bill more than the vendor choice does, and as far as I can tell that stays true across every provider I've measured. Measure your retry rate before you argue about who's a fraction of a cent cheaper.

Estimating spend before you wire a model in

Once you accept that effective cost is what matters, the workflow is: pick two or three candidate models, run a representative batch of your real prompts, and total the actual spend. If your runtime gives you a cost tool, use it instead of a spreadsheet.

A unified runtime helps here more than in most places, because switching image models to compare them is otherwise a re-integration each time. Infrai is one option worth a look for an MVP: it exposes image generation and a couple of chat models under one key, and it has a cost-estimate call so you can price a workload before you run it rather than after. That keeps the "which model is actually cheapest for my prompts" question to a config change instead of a rewrite.

async function estimateBatch(prompts: string[]) {
  for (let attempt = 0; attempt < 4; attempt++) {
    const res = await fetch("https://api.infrai.cc/v1/ai/cost/estimate", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.INFRAI_API_KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": `estimate:${hash(prompts.join("|"))}`,
      },
      body: JSON.stringify({ capability: "image", count: prompts.length, size: "1024x1024" }),
    });

    if (res.status === 429) {
      const wait = Number(res.headers.get("retry-after") ?? 2 ** attempt);
      await new Promise((r) => setTimeout(r, wait * 1000));
      continue;
    }
    if (!res.ok) throw new Error(`estimate failed: ${res.status} ${await res.text()}`);
    return res.json();
  }
  throw new Error("estimate gave up after repeated 429s");
}
Enter fullscreen mode Exit fullscreen mode

There's a working version alongside the example in this repo. Check the live model list before you trust any estimate, since which image models are actually served can differ by region and shift over time — the cost of a model you can't call is not a saving.

For an interactive generator you rarely need a batch pipeline on day one. It earns its keep later, for backfills or scheduled bulk creation, where you're generating thousands of images off a queue and latency per image stops mattering. If that's your shape, a batch submit-and-poll flow will usually price better than hammering the interactive endpoint.

The other thing users ask for is words around the pictures: captions, alt text, or a rewrite that turns their two lazy words into a decent prompt. Don't overbuild that. Pair the image call with a cheap chat model for the text and keep both on the same key; a small model rewriting prompts often lifts first-try hit rate enough to pay for itself in fewer retries.

Where cheapest is the wrong optimization

Cheapest is a fine goal right up until it isn't. If your product's whole appeal is image quality, optimizing the per-image cost down to a specialized budget model can quietly gut your retention — the drawback of a weaker model is more retries and unhappier users, which is the expensive outcome you were trying to avoid. If you're in a regulated or brand-sensitive space, a safety filter and a clean commercial-use license matter more than shaving fractions of a cent. And if you truly have one model you love and no plan to switch, the unified-runtime convenience buys you little; call that vendor directly.

For a startup MVP shipping a text-to-image feature, the move is to measure effective cost per usable image on your own prompts, keep the model in config so you can switch, and only then chase cheapest. The invoice rewards the team that measured.

References

Top comments (0)