Skip to main content

Depth to Image Endpoint

Overview

The V5 API Depth to Image endpoint allows for depth to generate a picture.

Pass the image URL with the init_image parameter and add your description of the desired modification to the prompt parameter.

Depth to image endpoint result

Request

--request POST 'https://stablediffusionapi.com/api/v5/depth2img' \

Make a POST request to https://stablediffusionapi.com/api/v5/depth2img endpoint and pass the required parameters in the request body.

Watch the how-to video to see it in action.

Body Attributes

ParameterDescription
keyYour API Key used for request authorization
promptText prompt with description of the things you want in the image to be generated
init_imageLink to the initial image

Example

Body

Body
{
"key": "",
"init_image" : "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" : "give him glasses"
}

Request

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

var raw = JSON.stringify({
"key": "",
"init_image" : "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" : "give him glasses"
});

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

fetch("https://stablediffusionapi.com/api/v5/depth2img", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response
{
"status": "success",
"generationTime": 1.322338581085205,
"id": 14754476,
"output": "https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/87e450a1-f0e6-4f95-a6c5-c081fd80f635-0.png"
}