Skip to content

Generating Product Shots with Transparent Backgrounds

This Workflow generates a studio product photograph and removes its background in a single API call, returning a transparent PNG ready to drop into a website or marketing asset.

Generated by Flux SchnellBackground removed
Studio product photograph of a stainless-steel coffee tumbler on a white backgroundSame coffee tumbler with the background removed, leaving just the product on transparency
Terminal window
# Create a project directory.
mkdir prodia-product-shots-workflow
cd prodia-product-shots-workflow

Install Node (if not already installed):

Terminal window
brew install node
# Close the current terminal and open a new one so that node is available.

Create project skeleton:

Terminal window
# Requires node --version >= 18
# Initialize the project with npm.
npm init -y
# Install the prodia-js library.
npm install prodia --save
Terminal window
# Export your token so it can be used by the main code.
export PRODIA_TOKEN=your-token-here

Your token is exported to an environment variable. If you close or switch your shell you’ll need to run export PRODIA_TOKEN=your-token-here again.

Create a main file for your project:

main.js
const { createProdia } = require("prodia/v2");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN // get it from environment
});

You’re now ready to make some API calls!

The chain has two jobs: a text-to-image generation, then inference.remove-background.v1 which replaces the background with transparency.

The remove-background processor returns two outputs — foreground (the transparent PNG you want) and mask (the binary alpha map). The Prodia SDK gives you the foreground automatically. For Python and curl, you need a multipart parser to pull foreground from the response — examples below.

main.js
const { createProdia } = require("prodia/v2");
const fs = require("node:fs/promises");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN,
});
(async () => {
const job = await prodia.job({
type: "workflow.serial.v1",
config: {
jobs: [
{
type: "inference.flux-fast.schnell.txt2img.v2",
config: {
prompt: "studio product photograph of a stainless-steel coffee tumbler on a plain white seamless background, soft even lighting, centred composition",
seed: 42,
},
},
{
type: "inference.remove-background.v1",
},
],
},
}, {
accept: "image/png",
});
const image = await job.arrayBuffer();
await fs.writeFile("product.png", new Uint8Array(image));
// open product.png
})();
Terminal window
node main.js
Terminal window
open product.png
  • Prompt for a clean background. Phrases like “plain white seamless background” or “studio backdrop” give the cut-out crisper edges than busy or photographic backgrounds.
  • Output is always PNG. inference.remove-background.v1 requires PNG output to preserve the alpha channel — JPEG would flatten it onto an opaque background.
  • Need only the mask? The chain still works if you read the mask part instead of foreground from the multipart response. See Removing Backgrounds for using the mask alone.