36 Ad Variations From 1 Product Photo Cost $0.33. Letting the Model Write the Headlines Costs $6.21.
1 product photo, 4 scenes, 3 ad sizes and 3 headlines make 36 ad variations for $0.33 with FLUX 2 Edit. Ask Nano Banana Pro Edit to paint each headline into the image instead, and the same 36 ads cost $6.21: 19 times more, for text you can’t edit.
Paid social runs on variations. You test 3 headlines against each other, in the 3 shapes the feeds and Stories use, over a few backgrounds, and you keep the one that wins. That is 36 creatives for one product before you have learned anything.
This post is the pipeline for that job: what each step costs at today’s prices on MegaBrain’s model pages, the 1 design decision that sets the bill, a Python script that does all 36, and how to run it from an AI agent.
The pipeline: 12 images, 36 ads
- Stage (image edit). FLUX 2 Edit puts your real product into 4 scenes: wet slate with eucalyptus, a bathroom shelf, beach sand, terracotta tile. Your photo goes in as the reference, so the bottle and label come from the photo, not from a guess.
- Resize by generating, not cropping. Each scene is generated 3 times, at 1:1, 4:5 and 9:16, so the composition fits each shape instead of losing the product to a crop. 4 scenes × 3 sizes = 12 edits.
- Copy (code). About 35 lines of Pillow draw each of 3 headlines and a “Shop now” button on every clean image. 12 images × 3 headlines = 36 ads. This step costs nothing and takes milliseconds.
The cost: $0.0092 per finished ad
FLUX 2 Edit is priced at $0.0138 per started megapixel, counting the output and each input image. Shrink the product photo to 1 megapixel and keep each output under 1,000,000 pixels, and every edit bills 2 megapixels: $0.0276. Here is the same job priced on the image-editing models MegaBrain lists, all at the per-image prices on their model pages.
| Model | Per image | 12 clean images → 36 ads | 36 ads, text baked in |
|---|---|---|---|
| FLUX 2 Edit (1 MP in, ≤1 MP out) | $0.0276 | $0.3312 | $0.9936 |
| MiniMax H3 Image Edit | from $0.0285 + inputs | from $0.342 | from $1.026 |
| Nano Banana Edit | $0.0458 | $0.5496 | $1.6488 |
| Seedream 4.5 Edit | $0.046 | $0.552 | $1.656 |
| Nano Banana Pro Edit (1K or 2K) | $0.1725 | $2.07 | $6.21 |
MiniMax H3 Image Edit’s page lists $0.0285 per image and notes that each input image adds to the price, so its row is a floor. The other prices are flat per image; Nano Banana Pro Edit doubles at 4K. Swapping models means swapping the size field too: the Nano Banana models take an aspect_ratio such as 4:5, and Seedream 4.5 Edit wants sides of at least 1024 px.
The cheapest way to make 36 ads is to make 12 images. Baking 3 headlines into the image triples the generations on any model, and on the priciest one the job goes from $0.33 to $6.21.
Why the headline belongs in code, not in the prompt
Image models have become good at drawing text, and Nano Banana Pro Edit is the one people reach for when they want it. For ad copy, it is still the wrong tool, for 4 reasons.
- Every headline is a new generation. 3 headlines on 12 backgrounds is 36 paid images, and the background changes each time, so your A/B test compares 2 things at once: the copy and the picture.
- A typo costs a regeneration. A misspelled word, a wrong price or a legal line the client changed on Friday means paying again and hoping the new image is as good as the old one.
- Your brand font isn’t in the model. Pillow draws with the TTF file your designer gave you, at the same size and position on every ad.
- Clean images keep working. The 12 backgrounds without text are reusable next month, for a new offer, a holiday headline or a different language.
Pay for model-drawn text when the text is part of the scene, not on top of it: a label on a shop sign in the background, a chalkboard menu, packaging the model has to redesign. That is a handful of images, not 36.
The 2 sizes that double the bill
| Setting | Careful | Careless | Over 12 edits |
|---|---|---|---|
| Square output | 992×992: 1 MP | 1024×1024: 2 MP | +$0.1656 |
| Input photo | Resized to 1 MP | 4032×3024 phone photo: 13 MP | +$1.9872 |
| One edit | $0.0276 | up to $0.2070 | $0.3312 vs up to $2.4840 |
1024×1024 looks like the natural square, but it is 1,048,576 pixels, just over 1 megapixel, so it bills 2. A 12-megapixel phone photo bills 13 megapixels as an input on every call, before the model draws anything. The script resizes the photo once, up front, and uses 992×992, 880×1104 and 736×1312, which stay under the line. We covered the same rule in the FLUX 2 prompting guide.
The script
The brief is a small JSON file: 4 scenes, 3 headlines and the button text. Keep scenes free of people and other brands, and vary the light and surface rather than the product.
{
"scenes": [
"on a wet slate stone next to fresh eucalyptus, soft morning window light",
"on a bathroom shelf with folded white towels, warm evening lamp light",
"on pale beach sand with a long shadow, bright midday sun",
"on a terracotta tile with dried orange slices, top-down studio light"
],
"headlines": [
"Glow in 7 days",
"Your skin, but rested",
"The serum that sold out twice"
],
"cta": "Shop now"
}The script calls one endpoint, the queue for FLUX 2 Edit, using the submit-and-poll pattern from the media API docs. A failed job is refunded, and the script stops with its request id.
"""ad_variations.py: 1 product photo + brief.json -> 36 ads.
4 scenes x 3 sizes = 12 FLUX 2 Edit calls; 3 headlines per image are drawn locally.
Usage: python ad_variations.py serum.jpg brief.json Inter-Bold.ttf
"""
import base64
import io
import json
import os
import sys
import time
import requests
from PIL import Image, ImageDraw, ImageFont
BASE = "https://getmegabrain.com/api/gateway/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MEGABRAIN_API_KEY']}"}
# Every size stays under 1,000,000 pixels, so the output bills 1 started megapixel.
SIZES = {"1x1": (992, 992), "4x5": (880, 1104), "9x16": (736, 1312)}
def shrink_to_data_uri(path, max_pixels=1_000_000):
"""FLUX 2 Edit also bills every started megapixel of the input: keep it at 1."""
img = Image.open(path).convert("RGB")
w, h = img.size
if w * h > max_pixels:
scale = (max_pixels / (w * h)) ** 0.5
img = img.resize((int(w * scale), int(h * scale)), Image.LANCZOS)
buf = io.BytesIO()
img.save(buf, "JPEG", quality=92)
return "data:image/jpeg;base64," + base64.b64encode(buf.getvalue()).decode()
def run(model, payload):
"""Submit a job to the queue and wait for the result."""
res = requests.post(f"{BASE}/queue/{model}", headers=HEADERS, json=payload)
res.raise_for_status()
job = res.json()
while True:
status = requests.get(job["status_url"], headers=HEADERS).json()["status"]
if status in ("COMPLETED", "FAILED"):
break
time.sleep(3)
if status == "FAILED":
raise RuntimeError(f"{model} failed and was refunded: {job['request_id']}")
return requests.get(job["response_url"], headers=HEADERS).json()
def wrap(draw, text, font, max_width):
lines, line = [], ""
for word in text.split():
test = f"{line} {word}".strip()
if line and draw.textlength(test, font=font) > max_width:
lines.append(line)
line = word
else:
line = test
return lines + [line]
def add_copy(base, headline, cta, font_path):
"""Headline band near the top, button near the bottom: exact text, your font."""
img = base.convert("RGB")
w, h = img.size
draw = ImageDraw.Draw(img, "RGBA")
size = w // 12
font = ImageFont.truetype(font_path, size)
small = ImageFont.truetype(font_path, size // 2)
lines = wrap(draw, headline, font, w * 0.85)
top, step = int(h * 0.14), int(size * 1.25)
draw.rectangle([0, top - size // 3, w, top + step * len(lines) + size // 4], fill=(0, 0, 0, 120))
for i, line in enumerate(lines):
draw.text((w // 2, top + i * step), line, font=font, fill="white", anchor="ma")
pad, y = size // 3, int(h * 0.80)
half = draw.textlength(cta, font=small) / 2
draw.rounded_rectangle(
[w / 2 - half - pad, y - pad, w / 2 + half + pad, y + size // 2 + pad],
radius=pad,
fill="white",
)
draw.text((w // 2, y), cta, font=small, fill="black", anchor="ma")
return img
photo = shrink_to_data_uri(sys.argv[1])
brief = json.load(open(sys.argv[2]))
font_path = sys.argv[3]
os.makedirs("ads", exist_ok=True)
for s, scene in enumerate(brief["scenes"], start=1):
for name, (w, h) in SIZES.items():
url = run("flux-2/edit", {
"prompt": (
f"Place this exact product in a new scene: {scene}. "
"Keep the product's shape, label and colors unchanged. "
"Leave calm empty space in the top third. No text, no people."
),
"image_urls": [photo],
"image_size": {"width": w, "height": h},
"output_format": "jpeg",
})["images"][0]["url"]
base = Image.open(io.BytesIO(requests.get(url).content))
base.save(f"ads/s{s}_{name}_clean.jpg", quality=92)
for k, headline in enumerate(brief["headlines"], start=1):
ad = add_copy(base, headline, brief["cta"], font_path)
ad.save(f"ads/s{s}_{name}_h{k}.jpg", quality=92)
print(f"scene {s}, {name}: {url}")pip install requests pillow
export MEGABRAIN_API_KEY="your key"
python ad_variations.py serum.jpg brief.json Inter-Bold.ttf
# -> ads/s1_1x1_h1.jpg ... ads/s4_9x16_h3.jpg: 36 ads, plus 12 clean backgroundsPrompt rules that save regenerations
- Ask for empty space where the copy goes. “Leave calm empty space in the top third” keeps the headline off the product. Without it, the model centers the bottle and the text band lands on the label.
- Say “no text.” An edit model sometimes invents a caption or a fake label. You are adding the words yourself.
- Freeze the product. “Keep the product’s shape, label and colors unchanged” is there so the model doesn’t redesign your packaging.
- Mind the 9:16 edges. On Stories and Reels the app draws its own buttons over the top and bottom of the screen, which is why the script puts the headline 14% down and the button at 80%, not at the very edges.
From the winning ad to a video ad
When one variation wins, animate its clean 9:16 image. A 5-second Kling 2.6 Pro image-to-video clip without sound costs $0.4025 on MegaBrain, 44 times one finished static ad. Our earlier post builds a week of Reels from 1 product photo with the same FLUX 2 Edit step. Spend video money on the creative that already proved itself, not on all 36.
Automate it: a fresh set every Monday
The script is 3 HTTP patterns and a Pillow function, so it runs anywhere. Put it in cron, or rebuild it in n8n or Make with an HTTP Request node, a Wait node and a loop on the status URL; do the text overlay in a code node or hand the clean images to your design tool.
If you run an assistant in Telegram or Slack, give it the script as a skill: “Every Monday at 8, write 4 new scenes for this product, run ad_variations.py and send me the 36 ads.” The Hermes Agent guide and the OpenClaw guide show how to connect each agent to the same API key.
To build the script yourself in Cursor, Claude Code or Codex, paste this prompt. The Claude Code guide and the Codex guide show how to run either agent on MegaBrain.
Build a Python CLI, ad_variations.py, that turns 1 product photo and a brief.json
({"scenes": [4 strings], "headlines": [3 strings], "cta": "string"}) into 36 static
ad images using the MegaBrain API: 4 scenes x 3 sizes x 3 headlines.
API: base URL https://getmegabrain.com/api/gateway/v1, header
Authorization: Bearer $MEGABRAIN_API_KEY. Docs: https://getmegabrain.com/docs/media
Steps:
1. Resize the photo with Pillow so width x height <= 1,000,000 pixels and send it
as a base64 JPEG data: URL (FLUX 2 Edit bills each started megapixel of input).
2. For each scene and each size (992x992, 880x1104, 736x1312): POST
/queue/flux-2/edit with image_urls=[photo], image_size={"width", "height"},
output_format "jpeg", and a prompt that keeps the product unchanged, leaves
empty space in the top third, and asks for no text and no people.
3. Poll status_url every 3 s until COMPLETED or FAILED, then GET response_url.
4. Save the clean image, then draw each headline (top band, semi-transparent
black, white text, wrapped to 85% width) and a white CTA button (bottom 20%)
with Pillow and a TTF font passed on the command line. Save ads/sN_SIZE_hK.jpg.
Keep it in one file, under 130 lines, with clear errors when a job fails.What this means for your content
Generate scenes, set type. Let the model do what only a model can do, stage your product in new light, and let code do what code does perfectly: put exact words in the same place on every ad. That split is the difference between $0.33 and $6.21.
Budget per finished ad. “$0.0138 per megapixel” tells you little until you multiply it out. Here a finished, sized, captioned ad costs about $0.0092, so 100 new creatives a month cost under $1 in generation.
Test copy for free. Once the 12 clean images exist, a fourth headline or a new language is a re-run of the overlay, not a new bill. Most of what an ad test learns is in the words.
For other models that edit images, the image editing API page lists every one MegaBrain serves with its live price.
FAQ
How much does it cost to make AI ad variations from one product photo?
On MegaBrain, a FLUX 2 Edit image at 1 megapixel or less from a 1-megapixel input photo costs $0.0276. 4 scenes in 3 ad sizes are 12 edits, $0.3312. Adding 3 headlines to each image with code makes 36 ads for the same $0.3312, about $0.0092 per finished ad.
Should the AI model write the headline into the ad image?
Usually not. Every headline baked into the image is a separate generation, so 36 ads with Nano Banana Pro Edit at $0.1725 each cost $6.21, and fixing one word means paying for a new image. Generating a clean background and drawing the text with code gives exact spelling, your brand font and free copy tests.
Which sizes do I need for Instagram, Facebook and TikTok ads?
Most social placements are covered by 3 shapes: square 1:1, vertical 4:5 for feeds and full-screen 9:16 for Stories, Reels and TikTok. In this pipeline they are 992×992, 880×1104 and 736×1312, each under 1,000,000 pixels so FLUX 2 Edit bills 1 megapixel of output.
Why does 1024×1024 cost twice as much as 992×992 on FLUX 2 Edit?
FLUX 2 Edit is billed per started megapixel of the output and of each input image. 1024×1024 is 1,048,576 pixels, just over 1 megapixel, so it bills 2. 992×992 is 984,064 pixels and bills 1.
Can I run the ad pipeline automatically?
Yes. The script is plain Python calling one API, so it runs from cron, from an n8n or Make HTTP flow, or as a scheduled job in an AI agent such as Hermes Agent or OpenClaw. MegaBrain University has setup guides for both agents.
Try it on MegaBrain. Every model in this post runs from 1 key and 1 pay-as-you-go balance, with a playground on each model page: FLUX 2 Edit at $0.0138 per megapixel, Nano Banana Pro Edit at $0.1725 per image, Kling 2.6 Pro image to video at $0.0805 per second without sound.
Full disclosure: MegaBrain sells pay-as-you-go API access to image, video and text models, including FLUX 2 Edit, Nano Banana Pro Edit, Nano Banana Edit, Seedream 4.5 Edit, MiniMax H3 Image Edit and Kling 2.6 Pro. MegaBrain is not affiliated with Black Forest Labs, Google, ByteDance, MiniMax, Kuaishou, Meta, TikTok, Anthropic, OpenAI, n8n or Make.
Sources
Pages opened November 20, 2026. All prices are MegaBrain’s, from the model pages and the media API docs on that day; per-ad and per-batch totals are our arithmetic from them.
- MegaBrain: FLUX 2 Edit model page (price, per-megapixel billing of output and inputs)
- MegaBrain: Nano Banana Pro Edit model page (price, resolutions, aspect ratios)
- MegaBrain: Nano Banana Edit model page
- MegaBrain: Seedream 4.5 Edit model page
- MegaBrain: MiniMax H3 Image Edit model page
- MegaBrain: Kling 2.6 Pro image-to-video model page
- MegaBrain: media generation API docs (queue, model parameters, refunds)
- MegaBrain blog: FLUX 2 Prompting Guide (why 1024×1024 bills 2 megapixels)
MegaBrain for Mac · an AI coworker
Give MegaBrain the task, not the steps.
It works on your files, writes documents, spreadsheets and decks, connects to your team’s tools and asks before anything risky. Free to start.
Newsletter
Stay in the loop
Get our latest AI research and guides. No spam, unsubscribe anytime.