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

# タスクのステータスを取得

> create エンドポイントが返す `poll_url` を使用して、任意の非同期タスクのステータスと結果を取得します

## 概要

このエンドポイントは、動画、画像、音楽、3D生成などのタスクタイプにまたがる統一された非同期ポーリングに使用します。

create レスポンスに `poll_url` が含まれている場合は、正確にそのパスを呼び出してください。画像モデルの中には、タスクベースのレスポンスを画像専用のステータスパス、または `/v1/tasks/{id}` のいずれかで返すものがあります。

## パスパラメータ

<ParamField path="id" type="string" required>
  create リクエストが返すタスクID。
</ParamField>

## レスポンス

<ResponseField name="id" type="string">
  標準的な非同期タスク識別子。
</ResponseField>

<ResponseField name="task_id" type="string">
  非同期タスク識別子の別名。
</ResponseField>

<ResponseField name="poll_url" type="string">
  create レスポンスが提供する場合の推奨ポーリングURL。
</ResponseField>

<ResponseField name="status" type="string">
  タスクステータス。`pending`、`processing`、`completed`、`failed` などです。キャンセルされたタスクは `failed` として表され、`cancelled: true` が付きます。
</ResponseField>

<ResponseField name="cancelled" type="boolean">
  キュー中の非同期タスクが実行前にキャンセルされた場合は `true` です。
</ResponseField>

<ResponseField name="cancellation_status" type="string">
  キャンセルマーカー。キャンセル成功時は `cancelled` です。
</ResponseField>

<ResponseField name="data" type="array">
  完了した画像タスクでは、生成された画像結果がここに返されます。画像タスクは `data[].url` に URL を返します。
</ResponseField>

<ResponseField name="progress" type="number">
  任意の進捗値です。実際の進捗値が利用できる場合のみ返されます。完了判定には `status` を使用してください。
</ResponseField>

<ResponseField name="video_url" type="string">
  タスクが完了して動画を生成した場合の結果アセットのURL。
</ResponseField>

<ResponseField name="video" type="object">
  利用可能な場合に `url`, `duration`, `width`, `height` を含む単一の動画ペイロード。
</ResponseField>

<ResponseField name="videos" type="array">
  上流が複数出力を返す場合の複数の動画ペイロード。
</ResponseField>

<ResponseField name="error" type="string">
  タスクが失敗したときのエラーメッセージ。
</ResponseField>

<ResponseField name="created" type="integer">
  利用可能な場合の作成タイムスタンプ。
</ResponseField>

<ResponseField name="updated" type="integer">
  利用可能な場合の最終更新タイムスタンプ。
</ResponseField>

<ResponseField name="model" type="string">
  利用可能な場合にタスクで使用されたモデル。
</ResponseField>

## エラー時の挙動

タスクが存在しない、期限切れ、または公開されている async-task 契約を通じて解決できない場合、TokenLab は次を返します:

```json theme={null}
{
  "error": {
    "message": "Task not found or no longer available.",
    "type": "invalid_request_error",
    "code": "async_task_not_found"
  }
}
```

## 例

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.tokenlab.sh/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
    -H "Authorization: Bearer sk-your-api-key"
  ```
</RequestExample>

```python Python theme={null}
import requests

poll_url = "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
response = requests.get(
    f"https://api.tokenlab.sh{poll_url}",
    headers={"Authorization": "Bearer sk-your-api-key"},
)
print(response.json())
```

```javascript JavaScript theme={null}
const pollUrl = '/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
const response = await fetch(`https://api.tokenlab.sh${pollUrl}`, {
  headers: { Authorization: 'Bearer sk-your-api-key' },
});
console.log(await response.json());
```
