Générez des modèles 3D à partir de texte ou d’images en utilisant Tripo3D et d’autres fournisseurs. Il s’agit d’une API asynchrone. La réponse de création renvoie un identifiant de tâche et peut, lorsqu’il est disponible, inclure un poll_url à utiliser en priorité.
Les opérations 3D publiques sont déduites de la forme de la requête : une requête avec seulement prompt devient text-to-3d, et une requête avec image ou image_url devient image-to-3d. Cet endpoint n’expose pas de champ de requête operation ; n’envoyez pas l’ancienne valeur 3d-generation.
Corps de la requête
model
string
défaut: "tripo-h3.1"
Modele a utiliser, par exemple tripo-h3.1 ou tripo-p1.0. Consultez GET /v1/models?recommended_for=3d avant de vous appuyer sur un type d entree ou un format de sortie precis.
Description textuelle du modèle 3D à générer.
Image encodée en Base64 pour la génération image-vers-3D.
URL de l’image pour la génération image-vers-3D.
Format de sortie : glb, fbx, obj ou usdz.
Niveau de qualité : draft, standard ou high.
Préréglage de style pour le modèle.
Seed pour une génération reproductible.
Un identifiant unique pour l’utilisateur final.
Réponse
ID de la tâche pour le suivi du statut.
Alias de l’identifiant de tâche asynchrone lorsque l’adaptateur le renvoie.
URL de polling prioritaire lorsqu’elle est disponible.
Statut de la tâche : pending, processing, completed ou failed.
Horodatage Unix de la création de la tâche.
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"
}