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.
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
Try the API used in this article
Free tier, transparent pricing, and a single REST endpoint for FLUX, Stable Diffusion, and Leonardo models.
