# 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.

Canonical: https://raywake.si/blog/product-photo-api-keep-label-text
Last updated: 2026-12-01

Published: 2026-12-01 · Raywake

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:

| Route | What gets regenerated | Label safety | Best for |
| --- | --- | --- | --- |
| A. Cut-out and composite | Only the background | The product pixels are your original photo | Catalog and listing images |
| B. Masked edit | Only the area your mask allows | High, check the output | Background and light changes with realistic shadows |
| C. Reference edit | The whole image, guided by your photo | Varies, always check | Lifestyle 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](https://raywake.si/docs/mcp) 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](https://raywake.si/docs/authentication)).
- **Quote before every run.** Each step below is quoted first and only runs after you approve the price. See the [spend control guide](https://raywake.si/blog/ai-agent-spend-control-api-mcp) for the full pattern, or the [n8n workflow](https://raywake.si/blog/n8n-quote-approve-generate-workflow) if a teammate should approve each price.

Read each model's full input schema with [`GET /v1/models/{model}`](https://raywake.si/docs/reference/models) 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

```raywake-component
{"type": "model-card", "model": "birefnet/v2", "label": "BiRefNet Background Removal V2"}
```

[BiRefNet V2](https://raywake.si/models/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](https://raywake.si/blog/birefnet-v2-background-removal) covers these settings in more depth.

Then generate an empty scene with any text-to-image model, for example [Nano Banana 2.1](https://raywake.si/models/google/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

```raywake-component
{"type": "model-card", "model": "openai/gpt-image-2.5/flare/edit", "label": "GPT Image 2.5 Flare edit"}
```

[GPT Image 2.5 Flare edit](https://raywake.si/models/openai/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.

```raywake-component
{"type": "code-tabs", "snippets": {"curl": "# Route A: quote the cut-out (nothing runs until you call /v1/generate with this quote_id)\ncurl -s https://api.raywake.com/v1/quotes \\\n  -H \"Authorization: Bearer $RAYWAKE_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -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}}'\n\n# Route B: quote the masked edit (white in the mask = may change, black = keep)\ncurl -s https://api.raywake.com/v1/quotes \\\n  -H \"Authorization: Bearer $RAYWAKE_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -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\"}}'\n\n# Then: POST /v1/generate with the same model, input and quote_id, plus an Idempotency-Key header.", "python": "import os, sys, time, uuid, requests\n\nAPI = \"https://api.raywake.com/v1\"\nH = {\"Authorization\": f\"Bearer {os.environ['RAYWAKE_API_KEY']}\"}\nTERMINAL = {\"succeeded\", \"failed\", \"needs_review\", \"submission_unknown\", \"needs_reconciliation\"}\n\ndef run(model, inp):\n    \"\"\"Quote, ask, then generate. Returns the output URLs, or None if not approved.\"\"\"\n    q = requests.post(f\"{API}/quotes\", headers=H, json={\"model\": model, \"input\": inp})\n    q.raise_for_status()\n    q = q.json()\n    if input(f\"{model}: {q['price_usd']} USD. Generate? [y/N] \").strip().lower() != \"y\":\n        return None\n    job = requests.post(f\"{API}/generate\", params={\"wait\": \"true\"},\n                        headers={**H, \"Idempotency-Key\": str(uuid.uuid4())},\n                        json={\"model\": model, \"input\": inp, \"quote_id\": q[\"quote_id\"]}).json()\n    while job[\"status\"] not in TERMINAL:\n        time.sleep(3)\n        job = requests.get(f\"{API}/jobs/{job['job_id']}\", headers=H).json()\n    if job[\"status\"] != \"succeeded\":\n        sys.exit(f\"{job['status']}: {job.get('error')}\")  # don't resubmit automatically\n    return [o[\"url\"] for o in job[\"outputs\"]]\n\n# Your own product photo at a public https URL that stays reachable during the job.\nPRODUCT = \"https://cdn.your-shop.example/serum-bottle.jpg\"\n\n# Route A: cut the product out (transparent PNG) and ask for the mask too.\ncutout = run(\"birefnet/v2\", {\n    \"image_url\": PRODUCT,\n    \"model\": \"General Use (Heavy)\",\n    \"operating_resolution\": \"2048x2048\",\n    \"output_mask\": True,\n})\nprint(cutout)\n\n# Route B: masked edit. White in the mask = may change, black = keep.\nEDIT_MASK = \"https://cdn.your-shop.example/serum-bottle-edit-mask.png\"\nshots = run(\"openai/gpt-image-2.5/flare/edit\", {\n    \"image_urls\": [PRODUCT],\n    \"mask_url\": EDIT_MASK,\n    \"prompt\": (\"Replace only the background with a bright marble bathroom counter, \"\n               \"soft window light from the left and a soft contact shadow under the bottle. \"\n               \"Do not change the bottle, the cap or any text on the label.\"),\n    \"image_size\": \"auto\",\n    \"quality\": \"high\",\n    \"num_images\": 4,\n    \"output_format\": \"png\",\n})\nprint(shots)", "javascript": "import readline from \"node:readline/promises\";\nimport { stdin, stdout } from \"node:process\";\n\nconst API = \"https://api.raywake.com/v1\";\nconst auth = { Authorization: `Bearer ${process.env.RAYWAKE_API_KEY}`, \"Content-Type\": \"application/json\" };\nconst TERMINAL = [\"succeeded\", \"failed\", \"needs_review\", \"submission_unknown\", \"needs_reconciliation\"];\nconst rl = readline.createInterface({ input: stdin, output: stdout });\n\nasync function call(path, init = {}) {\n  const res = await fetch(`${API}${path}`, { ...init, headers: { ...auth, ...init.headers } });\n  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);\n  return res.json();\n}\n\n// Quote, ask, then generate. Returns the output URLs, or null if not approved.\nasync function run(model, input) {\n  const quote = await call(\"/quotes\", { method: \"POST\", body: JSON.stringify({ model, input }) });\n  const answer = await rl.question(`${model}: ${quote.price_usd} USD. Generate? [y/N] `);\n  if (answer.trim().toLowerCase() !== \"y\") return null;\n  let job = await call(\"/generate?wait=true\", {\n    method: \"POST\",\n    headers: { \"Idempotency-Key\": crypto.randomUUID() },\n    body: JSON.stringify({ model, input, quote_id: quote.quote_id }),\n  });\n  while (!TERMINAL.includes(job.status)) {\n    await new Promise((resolve) => setTimeout(resolve, 3000));\n    job = await call(`/jobs/${job.job_id}`);\n  }\n  if (job.status !== \"succeeded\") throw new Error(`${job.status}: ${job.error}`); // don't resubmit automatically\n  return job.outputs.map((o) => o.url);\n}\n\nconst PRODUCT = \"https://cdn.your-shop.example/serum-bottle.jpg\";\n\n// Route A: transparent cut-out plus mask\nconsole.log(await run(\"birefnet/v2\", {\n  image_url: PRODUCT,\n  model: \"General Use (Heavy)\",\n  operating_resolution: \"2048x2048\",\n  output_mask: true,\n}));\n\n// Route B: masked edit (white = may change, black = keep)\nconsole.log(await run(\"openai/gpt-image-2.5/flare/edit\", {\n  image_urls: [PRODUCT],\n  mask_url: \"https://cdn.your-shop.example/serum-bottle-edit-mask.png\",\n  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.\",\n  image_size: \"auto\",\n  quality: \"high\",\n  num_images: 4,\n  output_format: \"png\",\n}));\nrl.close();"}, "label": "Quote and run Route A and Route B with an approval step"}
```

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

```raywake-component
{"type": "model-card", "model": "nano-banana-pro/edit", "label": "Nano Banana Pro 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](https://raywake.si/models/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](https://raywake.si/models/google/nano-banana-2.1/edit) (`google/nano-banana-2.1/edit`, 1 to 14 reference images) and [Seedream 5.5 edit](https://raywake.si/models/bytedance/seedream/v5.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](https://raywake.si/blog/ai-product-image-model-selection).

## 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.

| Model | Used for | Price |
| --- | --- | --- |
| [`birefnet/v2`](https://raywake.si/models/birefnet/v2) | Cut-out and mask | Up to $0.28 per run |
| [`google/nano-banana-2.1`](https://raywake.si/models/google/nano-banana-2.1) | Empty background scene | Up to $0.10 per run |
| [`openai/gpt-image-2.5/flare/edit`](https://raywake.si/models/openai/gpt-image-2.5/flare/edit) | Masked edit | Up to $0.10 (low), $0.13 (medium), $0.24 (high), $0.37 (xhigh), $0.72 (max or auto) per image |
| [`nano-banana-pro/edit`](https://raywake.si/models/nano-banana-pro/edit) | Reference 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.

## Related

- [FLUX.2 product labels and scannable barcodes](https://raywake.si/blog/flux-2-product-label-barcode) for generating the label artwork itself.
- [GPT Image 2.5 Flare vs Sunburst](https://raywake.si/blog/gpt-image-2-5-flare-vs-sunburst) if you are choosing between the two GPT Image 2.5 editors.
- [Product photography](https://raywake.si/create/product-photography) in the studio, if you want to try a brief before writing code.

```raywake-component
{"type": "cta", "id": "api", "label": "Read the API quickstart"}
```

## Related

- [Türkçe sürüm](https://raywake.si/tr/blog/urun-fotografi-api-etiketi-bozmadan)
- [Raywake Blog](https://raywake.si/blog)
