Image Generation API
Endpoints for programmatically creating images with our AI tools.
GET/api/image/product-photography-prompts
Retrieve a list of all available pre-defined scene instructions for the Product Photography endpoint.
Example Request
curl -X GET 'https://codingmantra.com/api/image/product-photography-prompts'Example Response
{
"data": [
{
"id": "minimalist-white",
"title": "E-commerce White Background",
"categoryId": "studio-minimalist",
"categoryTitle": "Studio & Minimalist",
"demoImageUrl": "https://..."
},
// ... more prompts
]
}POST/api/image/product-photography
Generate a professional product photograph by placing your product in a custom scene.
Request Body
Note: Either `promptId` or `scenePrompt` is required.
| Field | Type | Description |
|---|---|---|
| productImages | Array of Objects | Required. An array of product image objects. Each object must have either a `dataUrl` (a Base64 data URI) or a `url` (a public https URL pointing to a JPEG, PNG, or WEBP image). Also supports an optional `label` string and an optional `prompt` string. |
| promptId | string | Optional. The ID of a pre-defined scene instruction. Use this for curated scenes. Get available IDs from the `/api/image/product-photography-prompts` endpoint. |
| scenePrompt | string | Optional. A text description of the desired background or scene. Can be used alone or as an addition to a `promptId`. |
| logoImage | string | Optional. A public https URL of a logo to place on the image. |
| overlayText | string | Optional. Short text to overlay prominently on the image. |
| marketingText | string | Optional. More detailed marketing text or slogan. |
| aspectRatio | string | Optional. The desired output aspect ratio. Can be `'1:1'` (Square), `'16:9'` (Landscape), or `'9:16'` (Portrait). Default: `'1:1'`. |
| outputResult | string | Optional. The desired output format. Can be `'base64'` (default) to receive a data URI, or `'url'` to receive hosted image URLs. |
Example Request (with promptId)
curl -X POST 'https://codingmantra.com/api/image/product-photography' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"productImages": [
{ "url": "https://example.com/my-product.png", "label": "bottle" }
],
"promptId": "rustic-wood-table",
"scenePrompt": "with grapes and cheese",
"logoImage": "https://example.com/my-logo.png",
"aspectRatio": "16:9",
"outputResult": "url"
}'Example Response (outputResult: 'url')
{
"data": {
"imageUrl": "https://storage.googleapis.com/...",
"thumbnailUrl": "https://storage.googleapis.com/..."
}
}Example Response (outputResult: 'base64')
{
"data": {
"photoDataUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
}
}