Image Guided Editing Endpoint
Overview
V5 Picture to Picture endpoint is used to edit an image using a text prompt with the description of the desired changes.
Pass the image URL with the init_image
parameter and add your description of the expected result to the prompt
parameter.
Request
--request POST 'https://stablediffusionapi.com/api/v5/pix2pix' \
Make a POST
request to https://stablediffusionapi.com/api/v5/pix2pix endpoint and pass the required parameters in the request body.
Watch the how-to video to see it in action.
Body Attributes
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
prompt | Text prompt with description of the things you want in the image to be generated |
init_image | Link to the initial image |
image_guidance_scale | Image guidance scale |
steps | Number of denoising steps |
guidance_scale | Scale for classifier-free guidance (minimum: 1; maximum: 20) |
Example
Body
Body
{
"key": "",
"init_image" : "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
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" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://stablediffusionapi.com/api/v5/pix2pix", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"init_image" => "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" => "make him woman",
"image_guidance_scale" => 1,
"steps" => 50,
"guidance_scale" => 7
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://stablediffusionapi.com/api/v5/pix2pix',
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://stablediffusionapi.com/api/v5/pix2pix',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"init_image" : "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://stablediffusionapi.com/api/v5/pix2pix"
payload = json.dumps({
"key": "",
"init_image" : "https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png",
"prompt" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
})
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 \"init_image\" : \"https://d1okzptojspljx.cloudfront.net/generations/b3341a09-082e-474e-989f-72ec3f3bf7aa-0.png\",\n \"prompt\" : \"make him woman\",\n \"image_guidance_scale\" : 1,\n \"steps\" : 50,\n \"guidance_scale\" : 7\n}");
Request request = new Request.Builder()
.url("https://stablediffusionapi.com/api/v5/pix2pix")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 4.5880513191223145,
"id": 14624464,
"output": "https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/186bd505-607d-4627-bf00-dcf3b35bfdab-0.png"
}