Skip to main content

Upload Base64 Image and Crop

Overview

Stable Diffusion V3 APIs Upload Base64 Image and Crop endpoint is used to upload an image and crop it. Pass the appropriate request parameters to the endpoint.

Request

--request POST 'https://modelslab.com/api/v3/base64_crop' \

Send a POST request to https://modelslab.com/api/v3/base64_crop endpoint.

note

Make sure you are passing the image in base64 format.

Body Attributes

ParameterTypeDescriptionValues
keyStringYour API Key used for request authorization.key
imageStringThe image to be uploaded, converted to base64 format.URL
cropStringA flag indicating whether to crop the image upon uploading.true or false

Example

Body

Body Raw
{
"key": "",
"image": "data:image/png;base64,your_base_64_string",
"crop": "true"
}

Request

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

var raw = JSON.stringify({
"key": "",
"image": "data:image/png;base64,your_base_64_string",
"crop": "true"
});

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

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

Response

{
"status": "success",
"messege": "image uploaded",
"link": "https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/2789658481681896990.png"
}