Z Image API
Z Image 文生圖生成的完整 API 參考。
模型版本
此 API 支援一個模型版本:
快速比較
支援的長寬比
width:height 組合必須是以下之一:
1:1, 3:2, 2:3, 3:4, 4:3, 9:16, 16:9, 9:21
Z Image(文生圖)
端點
POST /api/v1/image/task
請求參數
必需
可選
請求範例
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'z-image',
prompt: 'A cinematic portrait of a traveler standing on a cliff at golden hour',
width: 16,
height: 9,
seed: 0
})
});
const { data } = await response.json();
const taskId = data.task_id;
回應格式
提交回應:
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_status": "submitted"
}
}
使用 GET /api/v1/image/{task_id} 輪詢。任務狀態包括:submitted、processing、succeed、failed。
成功的輪詢回應會在 data.task_result.images[].url 下提供生成圖像 URL。
最佳實務
width 和 height 使用比例值,而不是像素尺寸。
- 保持提示詞有描述性,同時聚焦主體、光線和構圖。
- 測試時需要可重現生成結果時,使用固定的
seed。