Text to 3D
Overview
This endpoint generates 3D image from text prompt while passing appropriate parameters
Request
--request POST 'https://modelslab.com/api/v3/txt_to_3d' \
Make a POST
request to https://modelslab.com/api/v3/txt_to_3d endpoint and pass the required parameters as a request body.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization. | key |
prompt | Text prompt with description of the things you want in the image to be generated. | string |
negative_prompt | Items you don't want in the image. | string |
steps | Number of denoising steps. | 21, 31, 41 |
guidance_scale | Scale for classifier-free guidance. | Minimum: 1, Maximum: 20 |
frame_size | Number of frames for the 3D image. | 256 |
seed | Seed used to reproduce results. Pass null for a random number. | integral value |
seconds | Number of seconds for the 3D image animation. | |
output_type | Type of the 3D image to generate. | "gif" or "ply" |
webhook | URL to receive a POST API call once the image generation is complete. | url |
track_id | ID returned in the response to the webhook API call for identification. | integral value |
Example
Body
Body
{
"key": "",
"prompt":"human face",
"guidance_scale":20,
"steps":31,
"frame_size":256,
"output_type":"gif",
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"prompt":"human face",
"guidance_scale":20,
"steps":31,
"frame_size":256,
"output_type":"gif",
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v3/txt_to_3d", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"prompt" => "human face",
"guidance_scale" => 20,
"steps" => 31,
"frame_size" => 256,
"output_type" => "gif",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v3/txt_to_3d',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v3/txt_to_3d',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"prompt":"human face",
"guidance_scale":20,
"steps":31,
"frame_size":256,
"output_type":"gif",
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v3/txt_to_3d"
payload = json.dumps({
"key": "",
"prompt":"human face",
"guidance_scale":20,
"steps":31,
"frame_size":256,
"output_type":"gif",
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n \"key\":\"\",\n \"prompt\":\"human face\",\n \"guidance_scale\":20,\n \"steps\":31,\n \"frame_size\":256,\n \"output_type\":gif,\n \"output_type\":null,\n \"track_id\":\"null\" \n }");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v3/txt_to_3d")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"generationTime": 10,
"id": 109658485,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/1d98b880-b44f-48c4-8966-fec335475ec9.gif"
],
"meta": {
"file_prefix": "1d98b880-b44f-48c4-8966-fec335475ec9",
"frame_size": 256,
"guidance_scale": 20,
"instant_response": "no",
"n_samples": 1,
"negative_prompt": "",
"outdir": "out",
"output_type": "gif",
"prompt": "human face",
"safetychecker": "no",
"seconds": 3,
"seed": 2593936086,
"steps": 31,
"temp": "no"
}
}