Product Photo Generation API
Generate product images from text descriptions via API.
Overview
The Product Photo Generation API uses advanced AI technology to quickly generate professional product showcase images from text descriptions. No photography equipment needed - just provide product descriptions and scene requirements to get high-quality commercial images. Supports generating 1-4 variants at once with multiple aspect ratio options.
Endpoint
POST https://api.aluo.ai/api/photo-generate/generateRequest Parameters
Submit using application/json format:
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Product description text |
size | string | No | Aspect ratio (default: 1:1) |
nVariants | number | No | Number of images: 1, 2, 4 (default: 1) |
outputFormat | string | No | png | jpeg | webp (default: png) |
resolution | string | No | 1K | 2K | 4K (optional) |
Supported Aspect Ratios: 1:1, 3:2, 2:3, 16:9, 9:16, 4:3, 3:4, 4:5, 5:4, 21:9
Response Format
Success Response
Note: After this API returns a taskId, image generation is complete. You can use the taskId to query the status endpoint for result URLs.
{
"code": 0,
"success": true,
"data": {
"provider": "ai-provider",
"model": "default",
"taskId": "task_123456789",
"prompt": "A red coffee mug on wooden table",
"size": "1:1",
"nVariants": 1
}
}Query Result Endpoint
GET https://api.aluo.ai/api/photo-generate/status?taskId=task_123456789{
"code": 0,
"success": true,
"data": {
"status": "SUCCESS",
"images": [
{ "url": "https://cdn.aluo.ai/result1.png" }
]
}
}Example Requests
cURL
# 步骤 1: 创建生成任务
curl -X POST https://api.aluo.ai/api/photo-generate/generate \
-H "Authorization: Bearer sk-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A red coffee mug on a wooden table, natural lighting",
"size": "1:1",
"nVariants": 1,
"outputFormat": "png"
}'
# 步骤 2: 查询任务结果(使用返回的 taskId)
curl -X GET "https://api.aluo.ai/api/photo-generate/status?taskId=task_123456789" \
-H "Authorization: Bearer sk-your-api-key-here"Node.js
const fetch = require('node-fetch');
// 步骤 1: 创建生成任务
const createResponse = await fetch(
'https://api.aluo.ai/api/photo-generate/generate',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk-your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'A red coffee mug on a wooden table, natural lighting',
size: '1:1',
nVariants: 1,
outputFormat: 'png'
})
}
);
const createResult = await createResponse.json();
const taskId = createResult.data.taskId;
// 步骤 2: 查询任务结果
const statusResponse = await fetch(
`https://api.aluo.ai/api/photo-generate/status?taskId=${taskId}`,
{
headers: {
'Authorization': 'Bearer sk-your-api-key-here'
}
}
);
const statusResult = await statusResponse.json();
if (statusResult.data.status === 'SUCCESS') {
console.log('Images:', statusResult.data.images);
} else if (statusResult.data.status === 'FAILED') {
console.error('Generation failed');
}Python
import requests
headers = {
'Authorization': 'Bearer sk-your-api-key-here',
'Content-Type': 'application/json'
}
# 步骤 1: 创建生成任务
create_response = requests.post(
'https://api.aluo.ai/api/photo-generate/generate',
headers=headers,
json={
'prompt': 'A red coffee mug on a wooden table, natural lighting',
'size': '1:1',
'nVariants': 1,
'outputFormat': 'png'
}
)
task_id = create_response.json()['data']['taskId']
# 步骤 2: 查询任务结果
status_response = requests.get(
f'https://api.aluo.ai/api/photo-generate/status?taskId={task_id}',
headers={'Authorization': 'Bearer sk-your-api-key-here'}
)
result = status_response.json()
if result['data']['status'] == 'SUCCESS':
print('Images:', result['data']['images'])
elif result['data']['status'] == 'FAILED':
print('Generation failed')Credits & Processing Time
| Variants | Free User | PRO User | Time |
|---|---|---|---|
| 1 image | 40 credits | 35 credits | Usually 10-30 sec |
| 2 images | 80 credits | 70 credits | |
| 4 images | 160 credits | 140 credits |
Credits Deduction: Credits are deducted by the client after obtaining the generated results. If generation fails (status: FAILED), no credits will be deducted.
Prompt Writing Tips
- Describe product features in detail (color, material, shape, etc.)
- Specify scene and environment (indoor/outdoor, lighting, etc.)
- Add atmosphere descriptions (minimalist, luxurious, cozy, etc.)
- Use specific angle and composition instructions
- Keep descriptions clear and concise, avoid being overly complex
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
Prompt is required | No prompt provided | Must provide product description text |
nVariants must be 1, 2, or 4 | Invalid variant count | Only 1, 2, 4 are supported |
Insufficient credits | Not enough credits | Recharge credits or reduce variant count |