Product Try-On API
Virtually try on products (apparel, accessories, etc.) on models or scenes.
GET/api/image/product-try-on-prompts
Retrieve a list of all available pre-defined scene instructions for the Product Try-On endpoint.
Example Request
curl -X GET 'https://codingmantra.com/api/image/product-try-on-prompts'Example Response
{
"data": [
{
"id": "try-on-suit",
"title": "Suit / Jacket on Model",
"categoryId": "fashion-apparel",
"categoryTitle": "👗 Fashion & Apparel",
"demoImageUrl": "https://..."
},
// ... more prompts
]
}POST/api/image/product-try-on
Virtually try on products on a model or place them in a generated scene.
Request Body
| Field | Type | Description |
|---|---|---|
| productImages | Array of Objects | Required. An array of product image objects. Each object must have either a `dataUrl` or `url`. Supports optional `label` and `prompt`. |
| mainImage | string | Optional. A data URI or URL of a person or scene to place the product on. If omitted, an AI model/scene will be generated. |
| prompt | string | Optional. Additional instructions for the scene or model style. |
| logoImage | string | Optional. A data URI or URL of a logo to place on the image. |
| logoPlacement | string | Optional. Instructions for logo placement (e.g., 'top-left', 'center'). |
| logoSize | number | Optional. A numeric value (0.1 to 0.5) representing the logo size as a percentage of the image. |
| referenceImage | string | Optional. A data URI or URL of a reference image to guide the style. |
| aspectRatio | string | Optional. Default: `'1:1'`. |
| outputResult | string | Optional. `'base64'` (default) or `'url'`. |
Example Request
curl -X POST 'https://codingmantra.com/api/image/product-try-on' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"productImages": [
{ "url": "https://example.com/jacket.png", "label": "leather jacket" }
],
"mainImage": "https://example.com/model.jpg",
"prompt": "urban street style",
"aspectRatio": "3:4"
}'Example Response
{
"data": {
"photoDataUri": "data:image/png;base64,..."
}
}