Enterprise: Controlnet Endpoint
- enterprise/system_details
- enterprise/restart_server
- enterprise/update_server
- enterprise/update_s3
- enterprise/clear_cache
- enterprise/schedulers_list
- enterprise/load_model
- enterprise/verify_model
- enterprise/get_all_models
- enterprise/delete_model
- enterprise/controlnet
- enterprise/text2img
- enterprise/text2video
- enterprise/text2video
- enterprise/inpaint
- enterprise/super_resolution
- enterprise/upload_image
Overview
This endpoint is used to generate ControlNet images.
tip
You can also use this endpoint to inpaint images with ControlNet. Just make sure to pass the link to the mask_image
in the request body.
Request
--request POST 'https://stablediffusionapi.com/api/v1/enterprise/controlnet' \
Send a POST
request to https://stablediffusionapi.com/api/v1/enterprise/controlnet endpoint.
Body Attributes
Parameter | Description |
---|---|
key | Your enterprise API Key used for request authorization |
prompt | Text prompt with description of required image modifications. Make it as detailed as possible for best results. |
negative_prompt | Items you don't want in the image |
init_image | Link to the Initial Image |
model_id | The ID of the model to be used. It can be public or your trained model. |
controlnet_model | ControlNet model ID. It can be from the models list or user trained. |
controlnet_type | ControlNet model type. It can be from the models list. |
auto_hint | Auto hint image;options: yes/no |
guess_mode | Set this to yes if you don't pass any prompt. The model will try to guess what's in the init_image and create best variations on its own. Options: yes/no |
mask_image | Link to the mask image for inpainting |
width | Max Height: Width: 1024x1024 |
height | Max Height: Width: 1024x1024 |
samples | Number of images to be returned in response. The maximum value is 4. |
scheduler | Use it to set a scheduler. |
num_inference_steps | Number of denoising steps (minimum: 1; maximum: 50) |
safety_checker | A checker for NSFW images. If such an image is detected, it will be replaced by a blank image. |
enhance_prompt | Enhance prompts for better results; default: yes, options: yes/no |
guidance_scale | Scale for classifier-free guidance (minimum: 1; maximum: 20) |
strength | Prompt strength when using init_image. 1.0 corresponds to full destruction of information in the init image. |
seed | Seed is used to reproduce results, same seed will give you same image in return again. Pass null for a random number. |
webhook | Set an URL to get a POST API call once the image generation is complete. |
track_id | This ID is returned in the response to the webhook API call. This will be used to identify the webhook request. |
loadbalancer | Enable load balancer; options: yes/no, default: no. |
info
To use the load balancer, you need to have more than 1 server. Pass the first server's API key, and it will handle the load balancing with the other servers.
Models
ControlNet available models:
- canny
- depth
- hed
- mlsd
- normal
- openpose
- scribble
- segmentation
Schedulers
This endpoint also supports schedulers. Use the "scheduler" parameter in the request body to pass a specific scheduler from the list below:
- DDPMScheduler
- DDIMScheduler
- PNDMScheduler
- LMSDiscreteScheduler
- EulerDiscreteScheduler
- EulerAncestralDiscreteScheduler
- DPMSolverMultistepScheduler
- HeunDiscreteScheduler
- KDPM2DiscreteScheduler
- DPMSolverSinglestepScheduler
- KDPM2AncestralDiscreteScheduler
- UniPCMultistepScheduler
- DDIMInverseScheduler
- DEISMultistepScheduler
- IPNDMScheduler
- KarrasVeScheduler
- ScoreSdeVeScheduler
Example
Body
Body Raw
{
"key": "enterprise_api_key",
"controlnet_model": "normal",
"controlnet_type" :"canny",
"model_id": "midjourney",
"auto_hint": "yes",
"guess_mode" : "no",
"prompt": "a model doing photoshoot, ultra high resolution, 4K image",
"negative_prompt": null,
"init_image": "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image": null,
"width": "512",
"height": "512",
"samples": "1",
"scheduler": "UniPCMultistepScheduler",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"guidance_scale": 7.5,
"strength": 0.55,
"seed": null,
"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": "",
"controlnet_model": "normal",
"controlnet_type" :"canny",
"model_id": "midjourney",
"auto_hint": "yes",
"guess_mode" : "no",
"prompt": "a model doing photoshoot, ultra high resolution, 4K image",
"negative_prompt": null,
"init_image": "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image": null,
"width": "512",
"height": "512",
"samples": "1",
"scheduler": "UniPCMultistepScheduler",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"guidance_scale": 7.5,
"strength": 0.55,
"seed": null,
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://stablediffusionapi.com/api/v1/enterprise/controlnet", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"controlnet_model" => "normal",
"controlnet_type" => "canny",
"model_id" => "midjourney",
"auto_hint" => "yes",
"guess_mode" => "no",
"prompt" => "a model doing photoshoot, ultra high resolution, 4K image",
"negative_prompt" => null,
"init_image" => "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image" => null,
"width" => "512",
"height" => "512",
"samples" => "1",
"scheduler" => "UniPCMultistepScheduler",
"num_inference_steps" => "30",
"safety_checker" => "no",
"enhance_prompt" => "yes",
"guidance_scale" => 7.5,
"strength" => 0.55,
"seed" => null,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://stablediffusionapi.com/api/v1/enterprise/controlnet',
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/v1/enterprise/controlnet',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"controlnet_model": "normal",
"controlnet_type": "canny",
"model_id": "midjourney",
"auto_hint": "yes",
"guess_mode": "no",
"prompt": "a model doing photoshoot, ultra high resolution, 4K image",
"negative_prompt": null,
"init_image": "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image": null,
"width": "512",
"height": "512",
"samples": "1",
"scheduler": "UniPCMultistepScheduler",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"guidance_scale": 7.5,
"strength": 0.55,
"seed": null,
"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://stablediffusionapi.com/api/v1/enterprise/controlnet"
payload = json.dumps({
"key": "",
"controlnet_model": "normal",
"controlnet_type": "canny",
"model_id": "midjourney",
"auto_hint": "yes",
"guess_mode": "no",
"prompt": "a model doing photoshoot, ultra high resolution, 4K image",
"negative_prompt": None,
"init_image": "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image": None,
"width": "512",
"height": "512",
"samples": "1",
"scheduler": "UniPCMultistepScheduler",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"guidance_scale": 7.5,
"strength": 0.55,
"seed": None,
"webhook": None,
"track_id": None
})
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 \"controlnet_model\": \"normal\",\n \"type\": \"canny\",\n \"model_id\": \"midjourney\",\n \"auto_hint\" : \"yes\",\n \"guess_mode\" : \"no\",\n \"prompt\": \"a model doing photoshoot, ultra high resolution, 4K image\",\n \"negative_prompt\": null,\n \"init_image\": \"https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png\",\n \"mask_image\": null,\n \"width\": \"512\",\n \"height\": \"512\",\n \"samples\": \"1\",\n \"scheduler\": \"UniPCMultistepScheduler\",\n \"num_inference_steps\": \"30\",\n \"safety_checker\": \"no\",\n \"enhance_prompt\": \"yes\",\n \"guidance_scale\": 7.5,\n \"strength\": 0.55,\n \"seed\": null,\n \"webhook\": null,\n \"track_id\": null\n}");
Request request = new Request.Builder()
.url("https://stablediffusionapi.com/api/v1/enterprise/controlnet")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"generationTime": 3.6150574684143066,
"id": 14905468,
"output": [
"https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/b989586c-0a5f-41fa-91de-1c5ed5498349-0.png"
],
"meta": {
"prompt": "mdjrny-v4 style a model doing photoshoot, ultra high resolution, 4K image",
"model_id": "midjourney",
"controlnet_model": "normal",
"controlnet_type": "canny",
"negative_prompt": "",
"scheduler": "UniPCMultistepScheduler",
"safetychecker": "no",
"auto_hint": "yes",
"guess_mode": "no",
"strength": 0.55,
"W": 512,
"H": 512,
"guidance_scale": 3,
"seed": 254638058,
"multi_lingual": "no",
"init_image": "https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_imgvar/input_image_vermeer.png",
"mask_image": null,
"steps": 20,
"full_url": "no",
"upscale": "no",
"n_samples": 1,
"embeddings": null,
"lora": null,
"outdir": "out",
"file_prefix": "b989586c-0a5f-41fa-91de-1c5ed5498349"
}
}