Skip to main content

Image to 3D Endpoint

Overview

The Image to 3D API generates an 3D character from an image.

Request

--request POST 'https://modelslab.com/api/v6/3d/image_to_3d' \

Make a POST request to https://modelslab.com/api/v6/3d/image_to_3d endpoint and pass the required parameters as a request body to the endpoint.

Body Attributes

ParameterDescription
key (required)Your API Key used for request authorization.
model_id (optional, default="instantmesh")Specifies the model to be used for the 3D generation.
image (required)The input image for 3D conversion.
render (optional, default=false)Whether to render a NeRF video of the 3D model.
foreground_ratio (required, default=0.85)Ratio of the foreground size to the image size. Only used when remove_bg is enabled.
remove_bg (optional, default=false)If true, removes the background from the image.
resolution (required, default=256, max=512)Specifies the resolution of the generated 3D model.
chunk_size (optional, default=8192, max=12000)Size of chunks used in the process (affects VRAM usage).
seed (optional, default=0)Random seed for reproducibility. If set to 0, a random seed will be generated.
temp (optional, default="no")If set to "yes", the output files will be saved in a temporary directory.

Example

Body

Body
{
"key": "",
"model_id": "instantmesh",
"image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/0335d02b-958a-4a7f-b7e4-a5f1e61efbf1-0.png",
"foreground_ratio": 0.85,
"remove_bg": false,
"resolution": 256,
"chunk_size": 8192,
"seed": 0,
"temp": "no"
}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key": "",
"model_id": "instantmesh",
"image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/0335d02b-958a-4a7f-b7e4-a5f1e61efbf1-0.png",
"foreground_ratio": 0.85,
"remove_bg": false,
"resolution": 256,
"chunk_size": 8192,
"seed": 0,
"temp": "no"
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://modelslab.com/api/v6/3d/image_to_3d", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response
{
"status": "success",
"generationTime": 10.62,
"id": 109655545,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/out/ae46c488-b66c-4aaa-9540-7355261d8d71.obj"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/out/ae46c488-b66c-4aaa-9540-7355261d8d71.obj"
],
"meta": {
"chunk_size": 8192,
"file_prefix": "ae46c488-b66c-4aaa-9540-7355261d8d71",
"foreground_ratio": ".85",
"image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/0335d02b-958a-4a7f-b7e4-a5f1e61efbf1-0.png",
"remove_bg": true,
"render": false,
"resolution": 256,
"seed": 3480183101,
"temp": "no"
}
}