API Documentation
APIImage To ImageProduct Photo

Product Photo

API documentation and implementation examples for the Product Photo model.

Part of the Image To Image / Product collection

API Endpoint

/v1/image-to-image/product

Request Parameters

background_image_urlstring

Optional URL for a custom background image

Example:[ "https://example.com/backgrounds/white_marble.jpg" ]
image_url(Required)string

URL of the product image to be processed

Example:[ "https://example.com/images/product123.jpg" ]
manual_placement_selectionstring

Specific position to place the product when using manual placement

Example:[ "center_horizontal" ]
Enum:[ "upper_left", "upper_right", "bottom_left", "bottom_right", "right_center", "left_center", "upper_center", "bottom_center", "center_vertical", "center_horizontal" ]
padding_valuesobject

Custom padding values for manual padding placement

bottominteger

Bottom padding in pixels

leftinteger

Left padding in pixels

rightinteger

Right padding in pixels

topinteger

Top padding in pixels

placement_typestring

Method for determining how the product is placed on the background

Example:[ "automatic" ]
Enum:[ "original", "automatic", "manual_placement", "manual_padding" ]
prompt(Required)string

Text prompt to guide the image processing

Example:[ "Place this product on a white background" ]

Code Examples

const apiKey = "YOUR_API_KEY"; fetch("https://api.stockimg.ai/v1/image-to-image/product", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}` }, body: JSON.stringify({ "background_image_url": "https://example.com/backgrounds/marble.jpg", "image_url": "https://example.com/images/product123.jpg", "placement_type": "automatic", "prompt": "Place product on marble background with soft shadows" }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));

Response Example

{ "has_nsfw_concepts": [ true ], "images": [ { "content_type": "example string", "file_data": "example string", "file_name": "example string", "file_size": 1, "height": 1, "url": "example string", "width": 1 } ], "prompt": "example string", "seed": 1 }

Response Fields

has_nsfw_concepts(Required)array [boolean]

Array indicating whether each image contains NSFW concepts

images(Required)array [object]

Array of generated images

Array items:
[item]object
content_typestring

Content type/MIME type of the image

file_datastring

Base64-encoded image data (if applicable)

file_namestring

Name of the image file

file_sizeinteger

Size of the image file in bytes

heightinteger

Height of the image in pixels

urlstring

URL of the generated image

widthinteger

Width of the image in pixels

prompt(Required)string

The prompt used to generate the images

seed(Required)integer

Seed value used for the generation