> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lululab.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 任务状态、结果和常见错误

POST /tasks 是异步操作。保存响应中的 id，用 GET /tasks/\{id} 查询。Pending、Created、Running 表示仍在处理；Succeeded 表示完成；Failed、Cancelled 表示未完成。生成内容在 output 中，失败原因在 errorMessage 中。

```bash 查询任务状态 theme={null}
curl "https://customer.lululab.ai/tasks/TASK_ID" \
  -H "Authorization: $LULULAB_API_KEY"
```

### 响应示例

创建成功只表示任务已受理；返回的 id 用于后续查询。output 的具体字段随工作流而变化。

| 字段 / 类型 | 必填 | 可选值与说明 |
| - | - | - |
| `id` (`string`) | 是 | 任务 ID；创建后立即保存，用于 GET /tasks/\{id}。 |
| `workflowId` (`string`) | 是 | 实际执行的工作流 ID。 |
| `status` (`string`) | 是 | Created · Pending · Running · Succeeded · Failed · Cancelled · 任务状态；Succeeded 才表示成功产出。 |
| `output` (`JSON \| null`) | 否 | 成功后返回方案或生成结果；结构随 workflowId 变化。 |
| `errorMessage` (`string \| null`) | 否 | 失败时的错误详情。 |
| `credits` (`integer \| null`) | 否 | 可用时返回本任务的积分消耗。 |

```json 任务刚创建 theme={null}
{
  "id": "TASK_ID",
  "workflowId": "ImageGenV2",
  "status": "Created",
  "output": null,
  "errorMessage": null
}
```

```json 任务完成 theme={null}
{
  "id": "TASK_ID",
  "workflowId": "ImageGenV2",
  "status": "Succeeded",
  "output": { "...": "Workflow-specific result; inspect the returned JSON" },
  "errorMessage": null
}
```

| 状态码 | 处理方法 |
| - | - |
| `400` | 检查 workflowId、模型设置和请求字段。 |
| `401 / 403` | 检查 API Key 是否有效、账户是否可使用该功能。 |
| `402` | 积分不足；充值后重新估算。 |
| `429` | 调用过于频繁；稍后重试。 |
| `5xx` | 服务暂不可用；先查询已提交任务，避免重复扣费。 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.