获取任务产物
GET/v1/tasks/{task_id}/artifacts
获取异步图片任务生成的图片。任务 SUCCESS 前返回空数组。
请求头
Authorizationstring必填Bearer <API_KEY>,须为任务所属用户的 API Key。
路径参数
task_idstring必填POST /v1/images/tasks返回的task_id。
返回值
HTTP 200。
task_idstring可选任务 ID。
artifactsobject[]可选图片列表,按生成顺序排列。
显示子字段(6)
keystring可选产物标识,依次为
image-1、image-2……typestring可选固定为
image。mime_typestring可选例如
image/png。content_urlstring可选查看地址,下载时不要携带 API Key。
download_urlstring可选带文件名的下载地址,下载时不要携带 API Key。
expires_atinteger可选上述地址的过期时间(Unix 秒),有效期 15 分钟。过期后重新调用本接口获取新地址。
错误
| HTTP | code | 原因与处理 |
|---|---|---|
| 404 | artifact_not_found / invalid_request_error | 任务不存在或不属于当前用户。 |
| 401 | — | API Key 无效、过期或已禁用。 |
| 503 | artifact_store_error | 图片存储暂不可用,稍后重试。 |
curl https://ling-light.com/v1/tasks/task_xxxxxxxxxxxxxxxx/artifacts \
-H "Authorization: Bearer $LINGLIGHT_API_KEY"const response = await fetch('https://ling-light.com/v1/tasks/task_xxxxxxxxxxxxxxxx/artifacts', {
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
},
})
console.log(response.status, await response.json())import os
import requests
response = requests.get(
"https://ling-light.com/v1/tasks/task_xxxxxxxxxxxxxxxx/artifacts",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
},
timeout=60,
)
print(response.status_code, response.json()){
"task_id": "task_xxxxxxxxxxxxxxxx",
"artifacts": [
{
"key": "image-1",
"type": "image",
"mime_type": "image/png",
"content_url": "https://media.example.com/signed/image-1.png",
"download_url": "https://media.example.com/signed/image-1.png?download=1",
"expires_at": 1795661760
}
]
}