By · · Updated

Product Photos with an API, Without Breaking the Label

Three API routes for AI product photos, from cut-out compositing to masked edits, with mask handling, a label check and USD prices from the live catalog.

A grey ceramic vase in front of a black backdrop that is peeled back to show white paper behind it.Türkçe oku ↗

The usual failure in AI product photos is the label. The bottle looks right, the light is right, and the brand name now has a letter missing. On a listing, that is not a style choice; it shows a different product.

This guide shows three ways to make product shots through the Raywake API, ordered from "the label cannot change" to "the label usually survives", with code, mask handling and a check you can run before anything goes live. Every step is quoted first, so you see the USD price before a job runs.

Why labels break

Image generation and most image editing redraw pixels. Small text is among the hardest things to redraw: a model knows what a label on a serum bottle usually looks like, not what your label says. So the safest pixel is the one the model never touches. That idea drives the three routes:

RouteWhat gets regeneratedLabel safetyBest for
A. Cut-out and compositeOnly the backgroundThe product pixels are your original photoCatalog and listing images
B. Masked editOnly the area your mask allowsHigh, check the outputBackground and light changes with realistic shadows
C. Reference editThe whole image, guided by your photoVaries, always checkLifestyle scenes where the product must be re-posed

Before you start

  • Your own product photo, sharp and well lit, at a public https:// URL that stays reachable until the job finishes. Using the MCP server instead? Ask the assistant to use a file from your computer; the local package uploads it to your private Raywake files with upload_file and puts the returned URL into the input.

  • An API key with generate and jobs:read, kept in RAYWAKE_API_KEY (Authentication).

  • Quote before every run. Each step below is quoted first and only runs after you approve the price. See the spend control guide for the full pattern, or the n8n workflow if a teammate should approve each price.

Read each model's full input schema with GET /v1/models/{model} before you change parameters. Unknown fields or values outside the allowed options are rejected with 400 before quoting.

Route A: cut out, generate a background, composite

BiRefNet Background Removal V2BiRefNet Background Removal V2Separate a subject from its background with BiRefNet V2.

BiRefNet V2 (birefnet/v2) separates the product from its background and returns a transparent image. Useful inputs:

  • model: General Use (Light) (default), General Use (Light 2K), General Use (Heavy) (slower, more accurate), Matting, Portrait or General Use (Dynamic).

  • operating_resolution: 1024x1024 (default), 2048x2048, or 2304x2304 with the Dynamic model. Higher helps with high-resolution photos.

  • output_mask: also return the mask. mask_only returns just the mask.

  • output_format: png (default), webp or gif.

The BiRefNet V2 guide covers these settings in more depth.

Then generate an empty scene with any text-to-image model, for example Nano Banana 2.1 (google/nano-banana-2.1, prompt: "an empty marble bathroom counter, soft window light from the left, shallow depth of field, no products"). Finally, composite your cut-out on top locally, so the label stays your original photo:

python
from PIL import Image

scene = Image.open("scene.png").convert("RGBA")          # generated background
product = Image.open("cutout.png").convert("RGBA")       # birefnet/v2 output, transparent
product.thumbnail((int(scene.width * 0.45), int(scene.height * 0.7)))
x = (scene.width - product.width) // 2
y = int(scene.height * 0.88) - product.height            # stand it on the counter line
scene.alpha_composite(product, (x, y))
scene.convert("RGB").save("product-shot.jpg", quality=95)

The trade-off: shadows and reflections are now your job. A soft blurred ellipse under the product goes a long way. Running the composite through a generative "harmonize" edit would put the label back at risk, which is what Route B handles more carefully.

Route B: masked edit that keeps the product

GPT Image 2.5 Flare editGPT Image 2.5 FlareGenerate GPT Image 2.5 Flare visuals, with a separate editing operation.

GPT Image 2.5 Flare edit (openai/gpt-image-2.5/flare/edit) takes your photo in image_urls (up to 16 images) and a mask_url. In this model's mask, white marks regions to edit and black marks regions to keep. Paint the product black and the background white, and the edit stays in the background.

You already have a product mask from Route A (output_mask: true). If that mask shows the product in white, invert it before using it here:

python
from PIL import Image, ImageOps

mask = Image.open("birefnet-mask.png").convert("L")
ImageOps.invert(mask).save("edit-mask.png")   # product black = keep, background white = edit

Host edit-mask.png next to your product photo and quote the edit. Other useful inputs: image_size (auto, the default, infers it from the input image), quality (low, medium, high, xhigh, max or auto; high is the default), num_images (1 to 10) and output_format (png, jpeg or webp). Keep the prompt explicit about what must not change.

# Route A: quote the cut-out (nothing runs until you call /v1/generate with this quote_id)
curl -s https://api.raywake.com/v1/quotes \
  -H "Authorization: Bearer $RAYWAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"birefnet/v2","input":{"image_url":"https://cdn.your-shop.example/serum-bottle.jpg","model":"General Use (Heavy)","operating_resolution":"2048x2048","output_mask":true}}'

# Route B: quote the masked edit (white in the mask = may change, black = keep)
curl -s https://api.raywake.com/v1/quotes \
  -H "Authorization: Bearer $RAYWAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-image-2.5/flare/edit","input":{"image_urls":["https://cdn.your-shop.example/serum-bottle.jpg"],"mask_url":"https://cdn.your-shop.example/serum-bottle-edit-mask.png","prompt":"Replace only the background with a bright marble bathroom counter, soft window light from the left and a soft contact shadow under the bottle. Do not change the bottle, the cap or any text on the label.","image_size":"auto","quality":"high","num_images":4,"output_format":"png"}}'

# Then: POST /v1/generate with the same model, input and quote_id, plus an Idempotency-Key header.

The Route B call above asks for four images at high, so its quote is up to $0.96 (4 × $0.24). Start with num_images: 1 while you tune the mask and prompt.

Route C: reference edit for lifestyle scenes

Nano Banana Pro editNano Banana ProExplore portraits, compositions and visual ideas. Start with words or bring an image into the studio to edit.

When the product has to appear in a new pose or in someone's hand, a mask won't do. Nano Banana Pro edit (nano-banana-pro/edit) takes one or more image_urls (your product photo, optionally a scene or style reference) and a prompt. It supports resolution (1K, 2K, 4K), num_images (1 to 4), aspect_ratio and seed. Other reference editors in the catalog follow the same pattern, such as Nano Banana 2.1 edit (google/nano-banana-2.1/edit, 1 to 14 reference images) and Seedream 5.5 edit (bytedance/seedream/v5.5/edit, up to 10).

Write the label into the prompt as a hard constraint, for example: "Keep the bottle's shape, colours and every word on the label exactly as in the reference image." Higher resolution gives small text more pixels to land on. Treat every output as a candidate: this route redraws the label, so some variations will drift. For how image models compare on product shots, see choosing an AI model for product images.

Check the label before it ships

For Route B, the product area should barely change. Measure it instead of judging it at thumbnail size:

python
from PIL import Image, ImageChops, ImageStat

orig = Image.open("original.png").convert("RGB")
edit = Image.open("edited.png").convert("RGB").resize(orig.size)
keep = Image.open("birefnet-mask.png").convert("L").resize(orig.size)  # white = product

diff = ImageChops.difference(orig, edit)
print("mean change inside the product (R, G, B):",
      [round(v, 1) for v in ImageStat.Stat(diff, mask=keep).mean])

Pick a threshold on a few known-good results, then reject anything above it. For Route C, compare a crop of the label side by side at 100% zoom, or run OCR on both crops and diff the text.

Prices

From each model's page on Raywake, 1 December 2026. The quote for your exact input is the number that counts.

ModelUsed forPrice
birefnet/v2Cut-out and maskUp to $0.28 per run
google/nano-banana-2.1Empty background sceneUp to $0.10 per run
openai/gpt-image-2.5/flare/editMasked editUp to $0.10 (low), $0.13 (medium), $0.24 (high), $0.37 (xhigh), $0.72 (max or auto) per image
nano-banana-pro/editReference edit$0.24 per image at 1K or 2K, $0.48 at 4K

All of them run on one USD balance, in the studio, the API and the MCP server alike, with no subscription.

Read the API quickstart
← All articles