Skip to content

AI product photography with an API

One decent photo of a product can become an entire catalogue: different surfaces, different lighting, seasonal backgrounds, ad crops. The trick is editing an existing photo rather than generating the product from scratch — the model has never seen your product, but it can relight and re-stage a real photo of it.

Input
1 photo

The real product, any clean shot

Output
n variations

One job per background

Masking
None

Instruction-based editing

Why editing beats generating

If you prompt a text-to-image model for "our ceramic mug", you get a ceramic mug — just not yours. Product photography has to preserve the actual object: its shape, its logo, its colourway.

Instruction-based editing solves that. You pass the real photo and describe the change, and the model keeps the subject while replacing what you asked it to replace. No mask, no segmentation step in your pipeline.

Background replacement

The workhorse call. One photo in, one restaged photo out.

curl
curl https://api.fastgencloud.com/v1/images/edits \
  -H "Authorization: Bearer $FASTGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "model": "image-edit",
      "image": "https://cdn.example.com/products/mug-white-bg.jpg",
      "prompt": "place the mug on a polished walnut desk beside an open notebook, warm morning window light, shallow depth of field"
    }'

Fanning out a catalogue

Each background is its own job, so run them concurrently. Give every request a stable Idempotency-Key derived from the product and the scene — a retry then replays the original job instead of paying twice.

JavaScript
const SCENES = [
  "on a marble kitchen counter, soft daylight from the left",
  "on a linen tablecloth outdoors, dappled sunlight, summer",
  "on a dark slate surface, dramatic side lighting, product-hero style",
  "held in a person's hands, cosy interior, bokeh background",
];

const jobs = await Promise.all(
  SCENES.map((scene, i) =>
    fetch("https://api.fastgencloud.com/v1/images/edits", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.FASTGEN_API_KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": `mug-white-${i}`,
      },
      body: JSON.stringify({
        model: "image-edit",
        image: productUrl,
        prompt: `place the product ${scene}`,
      }),
    }).then((r) => r.json()),
  ),
);
// → four job ids; poll each, or pass webhook_url and collect callbacks

Prompt patterns that work

Edit models respond to concrete, imperative instructions. Name the surface, the light and the framing.

  • Surface first: "on a polished walnut desk", "on brushed concrete", "on a linen tablecloth"
  • Then light: "soft morning window light", "dramatic side lighting", "even studio softbox"
  • Then optics if you care: "shallow depth of field", "product-hero framing", "45-degree angle"
  • One change per request. Background plus colour plus angle in a single instruction usually gets you one of the three
  • If the edit is too timid, raise steps to 20–30 and guidance to about 4 — the default is the fast distilled setting

Keeping the product honest

Generated imagery that misrepresents a product is a real commercial and legal risk, and it is also against the Acceptable Use Policy to present generated imagery as authentic where that misleads.

Practical rules: never let the model change the product itself, only its surroundings. Review before publishing. Disclose generated imagery where your market expects it — several jurisdictions now require it for advertising.

What it costs

Edits are billed per output image from a prepaid balance, so a four-scene fan-out costs four edits. A failed job refunds automatically. Current rates are on the pricing page — and because billing is prepaid, a bug in a batch loop stops at your balance rather than at your credit limit.

Frequently asked questions

Do I need to cut the product out first?
No. Instruction editing works on the photo as-is — a clean, well-lit shot on any background is enough. Cutouts do not hurt, but the pipeline does not need them.
Will the logo and text on my product survive?
Usually, if the source photo is sharp and the instruction is about the surroundings rather than the product. Small text is the first thing to degrade, so review hero shots before publishing.
Can I generate models wearing or holding the product?
Yes — "held in a person’s hands" style instructions work. If you need the same person across a campaign, train a character and generate them consistently.
How many can I run at once?
Submit as many concurrent jobs as you like; they queue independently. Rate limits and cold starts are covered in the errors and limits documentation.

Related

Start generating

Create an account, add a prepaid balance, and call the API with a key from the console. No subscription, no minimum, no per-seat pricing.

Get an API key