> ## 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モデル生成タスクを作成します

Tripo3Dやその他のプロバイダーを使用して、テキストまたは画像から3Dモデルを生成します。これは非同期 API です。作成レスポンスはタスク ID を返し、利用可能な場合は優先して使う `poll_url` も返します。

公開 3D operation はリクエスト形状から推定されます。`prompt` のみのリクエストは `text-to-3d`、`image` または `image_url` を含むリクエストは `image-to-3d` として扱われます。この endpoint は `operation` リクエストフィールドを公開していません。旧来の `3d-generation` 値は送信しないでください。

## リクエストボディ

<ParamField body="model" type="string" default="tripo-h3.1">
  使用するモデルです。例: `tripo-h3.1` または `tripo-p1.0`。特定の入力タイプや出力形式に依存する前に `GET /v1/models?recommended_for=3d` を確認してください。
</ParamField>

<ParamField body="prompt" type="string" required>
  生成する3Dモデルのテキスト説明。
</ParamField>

<ParamField body="image" type="string">
  Image-to-3D生成用のBase64エンコード済み画像。
</ParamField>

<ParamField body="image_url" type="string">
  Image-to-3D生成用の画像のURL。
</ParamField>

<ParamField body="format" type="string" default="glb">
  出力形式：`glb`、`fbx`、`obj`、または`usdz`。
</ParamField>

<ParamField body="quality" type="string" default="standard">
  品質レベル：`draft`、`standard`、または`high`。
</ParamField>

<ParamField body="style" type="string">
  モデルのスタイルプリセット。
</ParamField>

<ParamField body="seed" type="integer">
  再現可能な生成のためのシード値。
</ParamField>

<ParamField body="user" type="string">
  エンドユーザーの一意識別子。
</ParamField>

## レスポンス

<ResponseField name="id" type="string">
  ステータス確認（ポーリング）用のタスクID。
</ResponseField>

<ResponseField name="task_id" type="string">
  アダプタが返す場合の非同期タスク ID 別名です。
</ResponseField>

<ResponseField name="poll_url" type="string">
  利用可能な場合に返される優先ポーリング URL です。
</ResponseField>

<ResponseField name="status" type="string">
  タスクのステータス：`pending`、`processing`、`completed`、または`failed`。
</ResponseField>

<ResponseField name="created" type="integer">
  タスク作成時のUnixタイムスタンプ。
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tokenlab.sh/v1/3d/generations" \
    -H "Authorization: Bearer sk-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "tripo-h3.1",
      "prompt": "A detailed medieval castle with towers",
      "format": "glb",
      "quality": "high"
    }'
  ```

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

  response = requests.post(
      "https://api.tokenlab.sh/v1/3d/generations",
      headers={"Authorization": "Bearer sk-your-api-key"},
      json={
          "model": "tripo-h3.1",
          "prompt": "A detailed medieval castle with towers",
          "format": "glb",
          "quality": "high"
      }
  )

  task_id = response.json()["id"]
  print(f"Task ID: {task_id}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.tokenlab.sh/v1/3d/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk-your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'tripo-h3.1',
      prompt: 'A detailed medieval castle with towers',
      format: 'glb',
      quality: 'high'
    })
  });

  const data = await response.json();
  console.log(`Task ID: ${data.id}`);
  ```

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

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

  func main() {
      payload := map[string]interface{}{
          "model":   "tripo-h3.1",
          "prompt":  "A detailed medieval castle with towers",
          "format":  "glb",
          "quality": "high",
      }
      body, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/3d/generations", bytes.NewBuffer(body))
      req.Header.Set("Authorization", "Bearer sk-your-api-key")
      req.Header.Set("Content-Type", "application/json")

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

      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("Task ID: %s\n", result["id"])
  }
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.tokenlab.sh/v1/3d/generations');

  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => [
          'Content-Type: application/json',
          'Authorization: Bearer sk-your-api-key'
      ],
      CURLOPT_POSTFIELDS => json_encode([
          'model' => 'tripo-h3.1',
          'prompt' => 'A detailed medieval castle with towers',
          'format' => 'glb',
          'quality' => 'high'
      ])
  ]);

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

  $data = json_decode($response, true);
  echo "Task ID: " . $data['id'];
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "status": "pending",
    "created": 1706000000,
    "model": "tripo-h3.1"
  }
  ```
</ResponseExample>
