Stable Diffusion API Docs
๐ Welcome
The Stable Diffusion V3 APIs comes with these features:
- Faster speed;
- Inpainting;
- Image 2 Image;
- Negative Prompts.
The Stable Diffusion API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
The Stable Diffusion API is equipped with a NSFW checker. Any image detected as NSFW will be replaced by a blank image.
Be aware of the content of your images. We have a filter system to remove any child pornography. Multiple attempts will result in account suspension.
The Stable Diffusion API uses keys to authenticate the requests. Pass the key you've obtained from the API Key Page to the request body and follow all the endpoint processes accordingly.
Send JSON POST requests with data and links.
Do not send files as raw format, send publicly accessible links to them instead.
Here you will find information about the Stable Diffusion and Multiple AI APIs.
You can pass details to generate images using this API, without the need of GPU locally.
All API requests are authorized by a key. You can obtain one by signing up.
Request Body Descriptionโ
Stable Diffusion API Request Body Argumentsโ
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
model_id | The ID of the model to be used. It can be of either public or your trained model. |
prompt | Text prompt with description of the things you want in the image to be generated |
negative_prompt | Items you don't want in the image |
width | Max Height: Width: 1024x1024 |
height | Max Height: Width: 1024x1024 |
samples | Number of images to be returned in response. The maximum value is 4. |
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 |
seed | Seed is used to reproduce results, same seed will give you same image in return again. Pass null for a random number. |
guidance_scale | Scale for classifier-free guidance (minimum: 1; maximum: 20) |
multi_lingual | Allow multi lingual prompt to generate images. Set this to "yes" if you use a language different from English in your text prompts. |
panorama | Set this parameter to "yes" to generate a panorama image. |
self_attention | If you want a high quality image, set this parameter to "yes". In this case the image generation will take more time. |
upscale | Set this parameter to "yes" if you want to upscale the given image resolution two times (2x). If the requested resolution is 512 x 512 px, the generated image will be 1024 x 1024 px. |
embeddings | This is used to pass an embeddings model (embeddings_model_id). |
lora | This is used to pass a lora model (lora_model_id) |
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. |
All API requests require a header to be passed. Make sure you pass Content-Type: application/json
in the header as shown in the example below:
--header 'Content-Type: application/json'
Follow the links below for more information about Image Stable Diffusion API endpoints:
- Stable Diffusion API;
- Dreambooth Finetuning;
- Dreambooth API;
- Dreamnbooth API V4;
- Dreambooth Sandbox API;
- Enterprise Plan.
Visit our YouTube channel to see Stable Diffusion APIs in action.
Possible Error Responsesโ
Below are listed the most common errors that might occur while using the Stable Diffusion API.
Rate Limitโ
This error is returned when the same request has been sent multiple times.
{
"status": "error",
"message": "Rate limit exceeded",
"tips": "you are sending same request multiple times, spam filter is enabled, please wait for 30 seconds and try again"
}
Invalid Keyโ
This error is returned when the API key used for request authentication is invalid.
{
"status": "error",
"message": "Invalid Api Key",
"tip": "1. Make sure you are passing Content-Type: application/json in header. 2. Make sure you are doing POST request with valid JSON. 3. Make sure your JSON does not have error, use jsonlint to validate json array. 4. Make sure you have valid API key."
}
Failed Responseโ
This error is returned when the request has failed for some reason.
{
"status": "failed",
"id": "",
"message": "Failed, Try Again",
"output": ""
}
Validation Errorsโ
This error is returned when one of the required fields has not been set. In this example, the prompt field was not set:
{
"status": "error",
"message": {
"prompt": [
"The prompt field is required."
]
}
}
This error is returned when model_id has not been filled for an endpoint that requires it.
{
"status": "error",
"message": "Model id not found"
}