跳轉到主要內容
使用 Tripo3D 及其他供應商,透過文字或圖片生成 3D 模型。這是一個非同步 API。建立回應會返回任務身分,並且在可用時返回優先使用的 poll_url 公開 3D operation 會從請求形狀推導:僅包含 prompt 的請求解析為 text-to-3d,帶 imageimage_url 的請求解析為 image-to-3d。此 endpoint 不公開 operation 請求欄位;不要傳送舊的 3d-generation 值。

請求主體

model
string
預設值:"tripo-h3.1"
要使用的模型,例如 tripo-h3.1tripo-p1.0。依賴某個輸入類型或輸出格式前,請先查詢 GET /v1/models?recommended_for=3d
prompt
string
必填
要生成的 3D 模型文字描述。
image
string
用於圖片轉 3D 生成的 Base64 編碼圖片。
image_url
string
用於圖片轉 3D 生成的圖片 URL。
format
string
預設值:"glb"
輸出格式:glbfbxobjusdz
quality
string
預設值:"standard"
品質等級:draftstandardhigh
style
string
模型的風格預設。
seed
integer
用於可重現生成的種子值。
user
string
終端用戶的唯一識別碼。

回應 (Response)

id
string
用於輪詢狀態的任務 ID。
task_id
string
適配器返回時的非同步任務 ID 別名。
poll_url
string
可用時返回的優先輪詢 URL。
status
string
任務狀態:pendingprocessingcompletedfailed
created
integer
任務建立的 Unix 時間戳記。
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"
  }'
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}")
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}`);
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
$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'];
{
  "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "pending",
  "created": 1706000000,
  "model": "tripo-h3.1"
}