Text to 3D Endpoint
Overview
The Text to 3D endpoint generates a 3D object from a text-based prompt.
Open in Playground 🚀Request
--request POST 'https://modelslab.com/api/v6/3d/text_to_3d' \
Make a POST
request to https://modelslab.com/api/v6/3d/text_to_3d endpoint and pass the required parameters as a request body.
Body Attributes
Parameter | Description | Values |
---|---|---|
key (required) | API key for request authorization. | String |
prompt (required) | Text prompt to describe the 3D model to generate. | Default: "A full body mesh of a dog" |
resolution (required) | Resolution of the generated 3D model. | Integer (max: 512 , default: 256 ) |
output_format (optional) | Format of the generated 3D model. | obj , stl , ply (default: glb ) |
render (optional) | Whether to render a NeRF video of the generated 3D model. | Boolean (default: false ) |
negative_prompt (optional) | Text to exclude specific elements from the generated model. | String (default: "" ) |
guidance_scale (optional) | Balances the adherence to the prompt versus creativity in the generation. | Float (default: 1.0 ) |
num_inference_steps (optional) | Number of steps for generating the 3D model. | Integer (default: 10 ) |
ss_guidance_strength (optional) | Strength of style-space guidance for refinement. | Float (default: 7.5 ) |
ss_sampling_steps (optional) | Number of steps for style-space sampling. | Integer (range: 1–50, default: 12 ) |
slat_guidance_strength (optional) | Strength of slat guidance for model details. | Float (range: 0.0–10.0, default: 3.0 ) |
slat_sampling_steps (optional) | Number of steps for slat guidance sampling. | Integer (range: 1–50, default: 12 ) |
mesh_simplify (optional) | Degree of mesh simplification to optimize the output model. | Float (range: 0.90–0.98, default: 0.90 ) |
foreground_ratio (optional) | Ratio of the foreground size to the overall image size (used if remove_bg is enabled). | Float (default: 0.85 ) |
remove_bg (optional) | Removes the background from the generated model if enabled. | Boolean (default: false ) |
chunk_size (optional) | Size of processing chunks (affects VRAM usage). | Integer (max: 12000 , default: 8192 ) |
seed (optional) | Random seed for reproducibility; 0 generates a random seed. | Integer (default: 0 ) |
temp (optional) | Save output files in a temporary directory when set to "yes" . | String (default: "no" ) |
Example
Body
Body
{
"key": "",
"foreground_ratio": "0.85",
"prompt": "a ghost wearing white bedsheet",
"num_inference_steps": "30",
"resolution": 512,
"guidance_scale": "3",
"ss_sampling_steps": 50,
"slat_sampling_steps": 50,
"seed": 0,
"temp": "no",
"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": "",
"foreground_ratio": "0.85",
"prompt": "a ghost wearing white bedsheet",
"num_inference_steps": "30",
"resolution": 512,
"guidance_scale": "3",
"ss_sampling_steps": 50,
"slat_sampling_steps": 50,
"seed": 0,
"temp": "no",
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v6/3d/text_to_3d", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"foreground_ratio" => "0.85",
"prompt" => "a ghost wearing white bedsheet",
"num_inference_steps" => "30",
"resolution" => 512,
"guidance_scale" => "3",
"ss_sampling_steps" => 50,
"slat_sampling_steps" => 50,
"seed" => 0,
"temp" => "no",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/3d/text_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/v6/3d/text_to_3d',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"foreground_ratio": "0.85",
"prompt": "a ghost wearing white bedsheet",
"num_inference_steps": "30",
"resolution": 512,
"guidance_scale": "3",
"ss_sampling_steps": 50,
"slat_sampling_steps": 50,
"seed": 0,
"temp": "no",
"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/v6/3d/text_to_3d"
payload = json.dumps({
"key": "",
"foreground_ratio": "0.85",
"prompt": "a ghost wearing white bedsheet",
"num_inference_steps": "30",
"resolution": 512,
"guidance_scale": "3",
"ss_sampling_steps": 50,
"slat_sampling_steps": 50,
"seed": 0,
"temp": "no",
"webhook": null,
"track_id": null
})
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, "{\r\n \"key\" : \"\",\r\n \"foreground_ratio\": \"0.85\",\r\n \"prompt\": \"a ghost wearing white bedsheet\",\r\n \"num_inference_steps\": \"30\",\r\n \"resolution\": 512,\r\n \"guidance_scale\": \"3\",\r\n \"ss_sampling_steps\": 50,\r\n \"slat_sampling_steps\": 50,\r\n \"seed\": 0,\r\n \"temp\": \"no\",\r\n \"webhook\": null,\r\n \"track_id\": null\r\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/3d/text_to_3d")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"generationTime": 15.47,
"id": 109657557,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/out/ba5dd616-eb74-482c-8ee8-f8046687a8f3.obj"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/out/ba5dd616-eb74-482c-8ee8-f8046687a8f3.obj"
],
"meta": {
"chunk_size": 8192,
"file_prefix": "ba5dd616-eb74-482c-8ee8-f8046687a8f3",
"foreground_ratio": ".85",
"guidance_scale": 10,
"negative_prompt": "low quality",
"num_inference_steps": 10,
"prompt": "human face",
"remove_bg": true,
"render": false,
"resolution": 256,
"seed": 3815040680,
"temp": "no"
}
}