Tạo các mô hình 3D từ văn bản hoặc hình ảnh bằng cách sử dụng Tripo3D và các nhà cung cấp khác. Đây là một API bất đồng bộ. Phản hồi tạo trả về danh tính tác vụ và, khi có sẵn, cũng có thể bao gồm poll_url ưu tiên.
Các operation 3D công khai được suy luận từ hình dạng request: request chỉ có prompt được xử lý là text-to-3d, còn request có image hoặc image_url được xử lý là image-to-3d. Endpoint này không công khai trường request operation; đừng gửi giá trị legacy 3d-generation.
Nội dung yêu cầu
model
string
mặc định: "tripo-h3.1"
Model can dung, vi du tripo-h3.1 hoac tripo-p1.0. Hay goi GET /v1/models?recommended_for=3d truoc khi phu thuoc vao loai dau vao hoac dinh dang dau ra cu the.
Mô tả văn bản của mô hình 3D cần tạo.
Hình ảnh được mã hóa Base64 để tạo mô hình 3D từ hình ảnh.
URL của hình ảnh để tạo mô hình 3D từ hình ảnh.
Định dạng đầu ra: glb, fbx, obj, hoặc usdz.
quality
string
mặc định: "standard"
Mức chất lượng: draft, standard, hoặc high.
Phong cách thiết lập sẵn cho mô hình.
Seed để tạo kết quả có thể tái lập.
Một mã định danh duy nhất cho người dùng cuối.
Phản hồi
ID tác vụ để kiểm tra trạng thái (polling).
Bí danh của mã tác vụ bất đồng bộ khi được adapter trả về.
URL polling ưu tiên khi có sẵn.
Trạng thái tác vụ: pending, processing, completed, hoặc failed.
Dấu thời gian Unix của thời điểm tạo tác vụ.
cURL
Python
JavaScript
Go
PHP
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"
}