Read a stored task / 查询任务
curl --request GET \
--url https://apistable.com/v1/tasks/{id} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://apistable.com/v1/tasks/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.com/v1/tasks/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"task_id": "<string>",
"model": "<string>",
"modality": "<string>",
"status": "<string>",
"output_count": 2,
"fallback": true,
"created_at": "2023-11-07T05:31:56Z",
"duration_ms": 1,
"counts": {
"succeeded": 1,
"failed": 1,
"cancelled": 1,
"pending": 1
},
"billing": {
"initial_reserved_credits": 1,
"charged_credits": 1,
"released_credits": 1,
"remaining_reserved_credits": 1
},
"items": [
{
"item_id": "<string>",
"index": 1,
"status": "<string>",
"final_channel_type": "<string>",
"charged_credits": 1,
"attempts": [
{
"attempt_id": "<string>",
"channel_type": "<string>",
"status": "<string>",
"duration_ms": 1
}
],
"outputs": [
{
"output_id": "<string>",
"type": "<string>",
"status": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"assets": [
{
"role": "<string>",
"url": "<string>"
}
],
"metadata": {},
"title": "<string>"
}
]
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}接口参考
查询任务
逐项获取完成结果、状态和费用。
GET
/
v1
/
tasks
/
{id}
Read a stored task / 查询任务
curl --request GET \
--url https://apistable.com/v1/tasks/{id} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://apistable.com/v1/tasks/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.com/v1/tasks/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"task_id": "<string>",
"model": "<string>",
"modality": "<string>",
"status": "<string>",
"output_count": 2,
"fallback": true,
"created_at": "2023-11-07T05:31:56Z",
"duration_ms": 1,
"counts": {
"succeeded": 1,
"failed": 1,
"cancelled": 1,
"pending": 1
},
"billing": {
"initial_reserved_credits": 1,
"charged_credits": 1,
"released_credits": 1,
"remaining_reserved_credits": 1
},
"items": [
{
"item_id": "<string>",
"index": 1,
"status": "<string>",
"final_channel_type": "<string>",
"charged_credits": 1,
"attempts": [
{
"attempt_id": "<string>",
"channel_type": "<string>",
"status": "<string>",
"duration_ms": 1
}
],
"outputs": [
{
"output_id": "<string>",
"type": "<string>",
"status": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"assets": [
{
"role": "<string>",
"url": "<string>"
}
],
"metadata": {},
"title": "<string>"
}
]
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}当前为 API 预览。生成接口尚未接入供应商,成功认证后仍可能返回 503;不会创建任务或扣积分。
追踪完整生命周期
| 状态 | 含义 |
|---|---|
| queued / running | 等待容量或生成中。 |
| falling_back | 明确可回退失败项正在切渠道。 |
| reconciliation_required | 上游结果不明,不要重复提交。 |
| succeeded | 全部目标项成功。 |
| partially_succeeded | 全部项已终态,其中部分成功。 |
| failed / cancelled | 明确失败,或已支持且确认的取消。 |
读取独立结果项
同一父请求可以同时包含低价渠道和官方成功项,不能把最后一项的渠道应用到全部结果。以上简例省略输出 URL、错误与时间字段。{
"task_id": "task_example",
"status": "partially_succeeded",
"output_count": 4,
"counts": {
"succeeded": 3,
"failed": 1,
"cancelled": 0,
"pending": 0
},
"billing": {
"initial_reserved_credits": 240,
"charged_credits": 100,
"released_credits": 140,
"remaining_reserved_credits": 0
},
"items": [
{
"index": 0,
"item_id": "item_1",
"status": "succeeded",
"final_channel_type": "third_party",
"charged_credits": 20
},
{
"index": 1,
"item_id": "item_2",
"status": "succeeded",
"final_channel_type": "third_party",
"charged_credits": 20
},
{
"index": 2,
"item_id": "item_3",
"status": "succeeded",
"final_channel_type": "official",
"charged_credits": 60
},
{
"index": 3,
"item_id": "item_4",
"status": "failed",
"final_channel_type": null,
"charged_credits": 0
}
]
}
轮询而不重复生成
间隔查询原 task_id、遵守 Retry-After,长任务适当退避。其他项运行时仍可读取完成项。不要通过反复创建生成请求进行查询。 在返回的 expires_at 前下载文件。文件过期不改变历史成功状态,也不会自动退积分。授权
API key beginning as_. Keep on the server. Scope permissions are checked separately.
路径参数
Stored task ID / 已存任务 ID
响应
Stored task and per-item billing
Operation status. Possible states include queued, running, falling_back, reconciliation_required, succeeded, partially_succeeded, failed, and cancelled.
必填范围:
1 <= x <= 4Completed duration; currently zero for unfinished tasks.
必填范围:
x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes