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 use key
to authenticate requests. Pass the key you got from API Key Page to the request body and follow all enpoints processes accordingly. Send Json post request with data and links, don't send files as raw format, send accessible links instead.
This is Stable Diffusion and Multiple AI APIs, here you can pass details to generate images using API, without needs of GPU locally.
Here is how the request body of stable diffusion API looks like.
key : Your API Key
prompt : Your Prompt
samples : number of images you want in response
negative_prompt : Items you don't want in the image
init_image : link of Initial Image
mask_image : link of mask image for inpainting
width : Width of output image. Maximum size is 1024x768 or 768x1024 because of memory limits
height : Height of output image. Maximum size is 1024x768 or 768x1024 because of memory limits
prompt_strength : Prompt strength when using init image. 1.0 corresponds to full destruction of information in init image
num_inference_steps : Number of denoising steps (minimum: 1; maximum: 50)
guidance_scale : Scale for classifier-free guidance (minimum: 1; maximum: 20)
seed : Random seed. Leave blank to randomize the seed
webhook : webhook to call when image generation is completed
track_id : tracking id to track this api call
All Api Request requires an header to be passed
--header 'Content-Type: application/json'
Below are lists of Image Stable Diffusion API endpoints
These are the lists of errors references you are most likely to encounter while using stable diffusion API.
You get this error when you send same request multiple times
{
"status": "error",
"messege": "Rate limit exceeded",
"tips": "you are sending same request multiple times, spam filter is enabled, please wait for 30 seconds and try again"
}
You get this error when your api key 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."
}
You get this error, if the request fails for some reasons
{
"status": "failed",
"id": "",
"messege": "Failed, Try Again",
"output": ""
}
You get this error if one of the required field is not set. In the example below, the prompt
field was not set
{
"status": "error",
"messege": {
"prompt": [
"The prompt field is required."
]
}
}
Some other times, you also get error that looks like this structure below when model_id
is not filled for the endpoint that requires it
{
"status": "error",
"messege": "Model id not found"
}