All articles
May 2, 20269 min read·ImageAPI Team

How to Create AI Product Photography with an API

Use a single API call to generate clean ecommerce product photography that matches your brand. Lighting, backgrounds, props, and how to get consistent results.

EcommerceTutorials

If you sell anything online you need clean product photos and you need a lot of them. A single product can need ten variations. A new SKU lands every week. Hiring a studio for every shoot is not realistic for most stores. AI product photography fills the gap when done right.

When AI product photos work and when they do not

AI works very well for category banners, hero images, lifestyle shots, and props placed near a real product. It still struggles to render the exact label on a specific bottle or the precise stitching on a known shoe. Use AI for backgrounds and context. Use a real photo or a 3D render for the product itself when accuracy matters.

The base prompt template

Good product prompts have five parts. Subject. Surface. Light. Camera. Mood. Skip any of them and you get inconsistent results. Use the same template across your catalog so the look stays unified.

function productPrompt(item) {
  return [
    `Studio product photograph of ${item.subject}.`,
    `Placed on ${item.surface}.`,
    `Lit with ${item.lighting}.`,
    `Shot with ${item.camera}.`,
    `Mood: ${item.mood}.`,
    "Highly detailed, sharp focus, photorealistic, no watermark, clean composition.",
  ].join(" ");
}

const example = productPrompt({
  subject: "a matte black ceramic coffee mug",
  surface: "a light oak table with a folded linen napkin",
  lighting: "soft morning window light coming from the left",
  camera: "85mm lens, shallow depth of field",
  mood: "warm, calm, minimal",
});

Calling the API

Use FLUX 2 Klein 9B for daily catalog work and FLUX 2 Dev for hero images that go on the home page. The cost difference per image is small but the quality difference on tricky materials like glass and metal is visible.

const res = await fetch("https://api.imageapi.org/api/v1/generate/product", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMAGEAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: example,
    model: "flux-2-klein-9b",
    width: 1024,
    height: 1024,
    num_inference_steps: 32,
  }),
});

Generating consistent variations

For a product catalog you usually want three angles. Front, three quarter, and overhead. Build a tiny helper that loops the same subject through three camera prompts and returns all three URLs in one batch call. Same seed across the loop keeps lighting and color consistent.

Composing real products onto AI backgrounds

If your brand requires the actual product, generate the scene without the product, cut your real product photo in Photoshop or with rembg, and paste it onto the AI background. This hybrid approach gives you brand accuracy plus unlimited backgrounds.

Where this saves you the most money

  • Seasonal banners. Refresh the look every week without a shoot.
  • Marketplace listings. Generate clean white backgrounds at scale.
  • Lifestyle shots. Show the product in a context the photographer never visited.
  • Ad creative. Spin twenty variants for paid testing.

Frequently asked questions

Will Amazon or Shopify reject AI generated product photos?
Both platforms allow AI imagery as long as it accurately represents the product. Use AI for backgrounds and lifestyle shots, and use a real photo for the main product image to be safe.
How do I keep the same model and lighting across many products?
Use the same prompt template across all calls and pass a fixed seed. Same template plus same seed gives near identical lighting across different subjects.
Can I generate images that match my brand colors?
Yes. Add the hex codes or color names to the prompt. For example, write deep navy backdrop with warm sand accents. The model handles named palettes well.

Try the API used in this article

Free tier, transparent pricing, and a single REST endpoint for FLUX, Stable Diffusion, and Leonardo models.

Related reading