Skip to main content

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.

danger

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.

danger

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โ€‹

ParameterDescription
keyYour API Key used for request authorization
model_idThe ID of the model to be used. It can be of either public or your trained model.
promptText prompt with description of the things you want in the image to be generated
negative_promptItems you don't want in the image
widthMax Height: Width: 1024x1024
heightMax Height: Width: 1024x1024
samplesNumber of images to be returned in response. The maximum value is 4.
num_inference_stepsNumber of denoising steps (minimum: 1; maximum: 50)
safety_checkerA checker for NSFW images. If such an image is detected, it will be replaced by a blank image.
enhance_promptEnhance prompts for better results; default: yes, options: yes/no
seedSeed is used to reproduce results, same seed will give you same image in return again. Pass null for a random number.
guidance_scaleScale for classifier-free guidance (minimum: 1; maximum: 20)
multi_lingualAllow multi lingual prompt to generate images. Set this to "yes" if you use a language different from English in your text prompts.
panoramaSet this parameter to "yes" to generate a panorama image.
self_attentionIf you want a high quality image, set this parameter to "yes". In this case the image generation will take more time.
upscaleSet 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.
embeddingsThis is used to pass an embeddings model (embeddings_model_id).
loraThis is used to pass a lora model (lora_model_id)
webhookSet an URL to get a POST API call once the image generation is complete.
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook request.
caution

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:

tip

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"
}