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。