Skip to main content
GET
/
v1
/
task
/
{task_id}
获取图片任务状态
curl --request GET \
  --url https://api.qclawrouter.com/v1/task/{task_id}

Documentation Index

Fetch the complete documentation index at: https://docs.qclawrouter.com/llms.txt

Use this file to discover all available pages before exploring further.

说明

图像生成任务提交后,使用此接口轮询任务状态,直到状态变为 succeeded

请求示例

cURL
curl https://api.qclawrouter.com/v1/task/task_xxx \
  -H "Authorization: Bearer sk-your-api-key"
Python
import requests
import time

def wait_for_image(task_id, api_key):
    headers = {"Authorization": f"Bearer {api_key}"}
    while True:
        resp = requests.get(
            f"https://api.qclawrouter.com/v1/task/{task_id}",
            headers=headers
        )
        data = resp.json()
        if data["status"] == "succeeded":
            return data["output"]["url"]
        elif data["status"] == "failed":
            raise Exception(data["error"])
        time.sleep(3)  # 每3秒轮询一次

返回示例

处理中:
{
  "task_id": "task_xxx",
  "status": "processing",
  "progress": 50
}
完成:
{
  "task_id": "task_xxx",
  "status": "succeeded",
  "output": {
    "url": "https://cdn.qclawrouter.com/images/xxx.png"
  }
}

任务状态说明

状态说明
pending等待处理
processing处理中
succeeded生成成功
failed生成失败
生成的图片文件保存 14 天后自动删除,请及时下载保存。