Cost per approved ad image: divide usage.cost by what you keep

Cost per image is not what you pay per approved image. Sum usage.cost over your batches, divide by images kept, and see which model earns its price.

4 min readSume
All posts

Cost per approved image is total usage.cost divided by the number of images you kept, and it can rank models differently from the price list. Say a model costs $0.04 per image and gives one keeper in two: that is $0.08 per approved image. A $0.06 model with three keepers in four also lands at $0.08. Only your own review counts decide it.

The Image API docs say cost is the USD amount billed to your wallet, and failed or cancelled generations are not billed, so failures do not enter the sum.

What do I need to log?

For each call, three things: the model id, usage.cost from the response and how many of the returned images a reviewer approved. Token counts are always 0 in v1, so ignore them. The numbers below are made up to show the arithmetic, not Sume prices.

What does the calculation look like?

Group the rows by model, add costs and kept images, and divide. Skip any model with no keepers rather than dividing by zero.

from collections import defaultdict

rows = [  # model, usage.cost billed, images returned, images kept
    ("model-a", 0.16, 4, 2),
    ("model-a", 0.16, 4, 1),
    ("model-b", 0.24, 4, 3),
    ("model-b", 0.24, 4, 3),
]
spend, kept, made = defaultdict(float), defaultdict(int), defaultdict(int)
for model, cost, n, k in rows:
    spend[model] += cost
    kept[model] += k
    made[model] += n

for model in sorted(spend):
    if kept[model] == 0:
        print(model, "no keepers")
        continue
    per_kept = spend[model] / kept[model]
    rate = kept[model] / made[model]
    print(f"{model}: ${per_kept:.3f} per approved, {rate:.0%} kept")

How big a sample is enough?

Twenty or so images per model is a starting point, not a proof. Keep the prompt set fixed across models and have the same person review, otherwise you are measuring the reviewer.

Where can I cross-check the spend?

The usage ledger lists reserved, captured and refunded rows, and GET /v1/usage accepts a job_id filter, so you can match your own sum to the wallet for any single job.

Sources

Related posts

More in Pricing

All Pricing posts

Written by Sume