> ## 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.

# 獲取 3D 模型狀態

> 獲取 3D 生成任務的狀態與結果

輪詢此端點以檢查您的 3D 模型生成任務狀態。

<Info>
  如果建立回應中包含 `poll_url`，請優先直接呼叫該 URL 輪詢。`id` 與 `task_id` 應視為同一個非同步任務身分。

  如果該任務已不存在，或無法再從公開任務記錄中查詢到，TokenLab 會回傳 `async_task_not_found`，並附上訊息 `Task not found or no longer available.`
</Info>

## 路徑參數

<ParamField path="id" type="string" required>
  3D 生成任務 ID。
</ParamField>

## 回應

<ResponseField name="id" type="string">
  任務 ID。
</ResponseField>

<ResponseField name="task_id" type="string">
  可用時返回的非同步任務 ID 別名。
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態：`pending`、`processing`、`completed` 或 `failed`。
</ResponseField>

<ResponseField name="progress" type="integer">
  可選進度值。僅在任務提供真實進度時返回；請使用 `status` 判斷任務是否完成。
</ResponseField>

<ResponseField name="model_url" type="string">
  下載 3D 模型檔案的 URL（完成時）。
</ResponseField>

<ResponseField name="glb_url" type="string">
  下載 GLB 格式模型的 URL（可用時）。
</ResponseField>

<ResponseField name="fbx_url" type="string">
  下載 FBX 格式模型的 URL（可用時）。
</ResponseField>

<ResponseField name="error" type="string">
  錯誤訊息（失敗時）。
</ResponseField>

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

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

  task_id = "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

  while True:
      response = requests.get(
          f"https://api.tokenlab.sh/v1/tasks/{task_id}",
          headers={"Authorization": "Bearer sk-your-api-key"}
      )
      result = response.json()

      if result["status"] == "completed":
          print(f"3D Model URL: {result['model_url']}")
          break
      elif result["status"] == "failed":
          print(f"Error: {result['error']}")
          break

      time.sleep(5)  # Poll every 5 seconds
  ```

  ```javascript JavaScript theme={null}
  const taskId = 'ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';

  async function pollFor3DModel() {
    while (true) {
      const response = await fetch(
        `https://api.tokenlab.sh/v1/tasks/${taskId}`,
        { headers: { 'Authorization': 'Bearer sk-your-api-key' } }
      );

      const result = await response.json();

      if (result.status === 'completed') {
        console.log(`3D Model URL: ${result.model_url}`);
        return result.model_url;
      } else if (result.status === 'failed') {
        throw new Error(result.error);
      }

      await new Promise(r => setTimeout(r, 5000));
    }
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "encoding/json"
      "fmt"
      "net/http"
      "time"
  )

  func main() {
      taskID := "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

      for {
          req, _ := http.NewRequest("GET",
              fmt.Sprintf("https://api.tokenlab.sh/v1/tasks/%s", taskID), nil)
          req.Header.Set("Authorization", "Bearer sk-your-api-key")

          client := &http.Client{}
          resp, _ := client.Do(req)

          var result map[string]interface{}
          json.NewDecoder(resp.Body).Decode(&result)
          resp.Body.Close()

          if result["status"] == "completed" {
              fmt.Printf("3D Model URL: %s\n", result["model_url"])
              break
          } else if result["status"] == "failed" {
              fmt.Printf("Error: %s\n", result["error"])
              break
          }

          time.Sleep(5 * time.Second)
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $taskId = 'ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';

  while (true) {
      $ch = curl_init("https://api.tokenlab.sh/v1/tasks/{$taskId}");

      curl_setopt_array($ch, [
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_HTTPHEADER => [
              'Authorization: Bearer sk-your-api-key'
          ]
      ]);

      $response = curl_exec($ch);
      curl_close($ch);

      $result = json_decode($response, true);

      if ($result['status'] === 'completed') {
          echo "3D Model URL: {$result['model_url']}\n";
          break;
      } elseif ($result['status'] === 'failed') {
          echo "Error: {$result['error']}\n";
          break;
      }

      sleep(5);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 回應 (已完成) theme={null}
  {
    "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "status": "completed",
    "model_url": "https://cdn.tripo3d.ai/abc123.glb",
    "glb_url": "https://cdn.tripo3d.ai/abc123.glb",
    "fbx_url": "https://cdn.tripo3d.ai/abc123.fbx"
  }
  ```
</ResponseExample>
