Docs
Stable Diffusion API

Stable Diffusion API

Complete documentation for GoAPI's Stable Diffusion API

Using our Stable Diffusion API helps you generate images without the need for:

  1. An expensive desktop computer with high-end GPUs
  2. Deploying Automatic 1111 WebUI locally
  3. Downloading CheckPoint and/or LoRA models

You can use any public models from our lists of available CheckPoints and LoRA models. If you would like to use other models from websites such as Civitai, Huggingface, or your own models, please contact us using the form on our website.

Images processed via the API are stored for 7 days post-processing for user downloads. Please download any necessary images within this period.


Available Endpoints

  • txt2img
  • img2img
  • fetch
  • upscale
  • controlnet

txt2img

POST

https://api.midjourneyapi.xyz/sd/txt2img

The text-to-image endpoint generates an image from a text prompt. Most of the time this endpoint returns the output image url from the request (if it does not, please use the Fetch endpoint a few seconds later to fetch the image url). Please see below for a list of CheckPoint Models you can use.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️The API Key where you would like to redeem your credits
Body
NameTypeRequiredDescription
model_idstringThe ID of the checkpoints model to be used, any available public models in Civitai
promptstringText prompt with description of the the things you want in the image to be generated
negative_promptstringText prompt with description of the things you don’t want in the image to be generated
widthstringHorizontal resolution, maximum: 1024
heightstringVertical resolution, maximum: 1024
seedintegerA numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_modelstringMulti LoRA is supported, pass comma saparated lora_model_id. Example: moxin, contrast-fix
lora_strengthfloatControls how much the checkpoint model is fine-tuned by the LoRA
num_inference_stepsstringthe number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scalefloata floating-point number used to measure the scale for classifier-free guidance. It should be within the range of 1 to 20, where a higher value indicates a higher degree of guidance.

Response Codes:

200
Success
400
The request does not meet requirements
401
The API Key is incorrect
500
The service is experiencing an error

Sample Request

curl -X POST \
	-H "X-API-KEY: YOUR_API_KEY " \
	-H "Content-Type: application/json" \
	-d '{
	  "model_id": "midjourney",
	  "prompt": "a cat",
	  "negative_prompt": "best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
	  "width": "512",
	  "height": "512",
	  "seed": null,
	  "lora_model": null,
	  "lora_strength": null
	}' \
	https://api.midjourneyapi.xyz/sd/txt2img

Sample Response

{
    "status": "success",
    "generationTime": 6.530880689620972,
    "id": 28225389,
    "output": [
        "https://img.midjourneyapi.xyz/sd/0-6b2f25d9-8b06-4853-a99e-379b06bb156e.png"
    ],
    "meta": {
        "prompt": "mdjrny-v4 style a cat",
        "model_id": "midjourney",
        "negative_prompt": "best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
        "W": 512,
        "H": 512,
        "seed": 4107109214,
        "steps": 30,
        "lora": ""
    }
}

img2img

POST

https://api.midjourneyapi.xyz/sd/img2img

The image-to-image endpoint generates an image from an initial image URL and a description prompt passed in the request body. You can specify model by using the model_id parameter.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
model_idstringThe ID of the checkpoints model to be used, any available public models in Civitai
promptstringText prompt with description of the the things you want in the image to be generated
negative_promptstringText prompt with description of the things you don’t want in the image to be generated
init_imagestringURL link to the initial image
strengthfloatPrompt strength when using init image, 1.0 corresponds to full destruction of information in the init image
widthstringHorizontal resolution, maximum: 1024
heightstringVertical resolution, maximum: 1024
seedintegerA numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_modelstringMulti LoRA is supported, pass comma saparated lora_model_id. Example: moxin, contrast-fix
lora_strengthfloatControls how much the checkpoint model is fine-tuned by the LoRA
num_inference_stepsstringthe number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scalefloata floating-point number used to measure the scale for classifier-free guidance. It should be within the range of 1 to 20, where a higher value indicates a higher degree of guidance.

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Sample Request

curl -X POST \
	-H "X-API-KEY: YOUR_API_KEY " \
	-H "Content-Type: application/json" \
	-d '{
	  "model_id": "anything-v5",
        "prompt": "best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
        "negative_prompt": "bad quality,low details,watermark,hands",
        "init_image": "https://img.midjourneyapi.xyz/sd/0-6b2f25d9-8b06-4853-a99e-379b06bb156e.png",
        "strength": 0.8,
        "width": "512",
        "height": "512",
        "seed": null,
        "lora_model": null,
        "lora_strength": null
     }' \
     "https://api.midjourneyapi.xyz/sd/img2img"

Sample Response

{
    "status": "success",
    "generationTime": 2.630248785018921,
    "id": 30589866,
    "output": [
        "https://img.midjourneyapi.xyz/sd/0-eabe6b9a-6e3a-4a10-95e5-4f198c126b01.png"
    ],
    "meta": {
        "prompt": " best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
        "model_id": "anything-v5",
        "negative_prompt": "bad quality,low details,watermark,hands",
        "init_image": "https://img.midjourneyapi.xyz/sd/0-77b8a8cf-c624-435f-95f2-482c041c3fa6.png",
        "strength": 0.8,
        "W": 512,
        "H": 512,
        "seed": 820764456,
        "steps": 30,
        "lora": ""
    }
}

Fetch

POST

https://api.midjourneyapi.xyz/sd/fetch

The fetch endpoint fetches the corresponding queued images. Usually multiple images or complex image generation requests take more time for processing, such requests are being queued for processing and the output images are retrievable after sometime. This endpoint doesn't generate new images, it returns already queued images and helps you keep track of your jobs.

Parameters:

Body
NameTypeRequiredDescription
idinteger✔️Returned by the id parameter in the response upon generation request

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Sample Request

curl -X POST -H "Content-Type: application/json" -d '{
  "id": 30588303
}' "https://api.midjourneyapi.xyz/sd/fetch"

Sample Response

{
    "id": 28227262,
    "output": [
        "https://img.midjourneyapi.xyz/sd/0-dfeac4f8-4fa3-4b4d-a5f2-ba8349b7dac6.png"
    ],
    "status": "success"
}

Upscale

POST

https://api.midjourneyapi.xyz/sd/upscale

The upscale endpoint returns the corresponding upscaled image of the image passed.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
urlstring✔️URL of the image that you want to upscale
scaleintegerA number for scaling the image

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Sample Request

curl -X POST -H "X-API-KEY: YOUR_API_KEY" -H "Content-Type: application/json" -d '{
  "url": "https://img.midjourneyapi.xyz/sd/0-77b8a8cf-c624-435f-95f2-482c041c3fa6.png",
  "scale": 2
}' "https://api.midjourneyapi.xyz/sd/upscale"

Sample Response

{
    "generationTime": 7.332714319229126,
    "id": 30591185,
    "output": "https://cdn.stablediffusionapi.com/generations/1690188415_out.png",
    "status": "success"
}
 

ControlNet

POST

https://api.midjourneyapi.xyz/sd/controlnet

The controlnet endpoint adds extra conditions for image generation. It can control the final image generation through various techniques like pose, edge detection, depth maps, and many more.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
model_idstring✔️The ID of the checkpoints model to be used, any available public models in Civitai
promptstringText prompt with description of the the things you want in the image to be generated
negative_promptstringText prompt with description of the things you don’t want in the image to be generated
widthstringHorizontal resolution, maximum: 1024
heightstringVertical resolution, maximum: 1024
seedintegerA numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_modelstringMulti LoRA is supported, pass comma separated lora_model_id. Example: moxin, contrast-fix
lora_strengthfloatControls how much the checkpoint model is fine-tuned by the LoRA
init_imagestring✔️URL link to the initial image
strengthfloatPrompt strength when using init image, 1.0 corresponds to full destruction of information in the init image
controlnet_typestringThe type of controlnet preprocessor
controlnet_modelstring✔️The ID of the controlnet model to be used
controlnet_imagestringURL link to the image used by controlnet
controlnet_conditioning_scalefloatScale for controlnet guidance (minimum: 1; maximum: 20)
num_inference_stepsstringthe number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scalefloata floating-point number used to measure the scale for classifier-free guidance. It should be within the range of 1 to 20, where a higher value indicates a higher degree of guidance.

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

controlnet_type and controlnet_model accept the same value

API Request

curl -X POST -H "X-API-KEY: YOUR_API_KEY" -H "Content-Type: application/json" -d '{
  "model_id": "ghostmix",
  "prompt": "best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
  "negative_prompt": "bad quality,low details,watermark,hands",
  "init_image": "https://i.imgur.com/X17rXVy.png",
  "control_image": "https://i.imgur.com/X17rXVy.png",
  "mask_image": "https://i.imgur.com/X17rXVy.png",
  "width": "512",
  "height": "512",
  "controlnet_model": "canny",
  "controlnet_type": "canny",
  "strength": 0.8,
  "controlnet_conditioning_scale": 1
}' "https://api.midjourneyapi.xyz/sd/controlnet"

Response

{
    "status": "processing",
    "eta": 65.3969803776,
    "id": 30592845,
    "messege": "Try to fetch request after seconds estimated",
    "meta": {
        "prompt": " best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below",
        "model_id": "ghostmix",
        "controlnet_model": "canny",
        "controlnet_type": "canny",
        "negative_prompt": "bad quality,low details,watermark,hands",
        "guess_mode": "no",
        "init_image": "https://i.imgur.com/X17rXVy.png",
        "control_image": "",
        "mask_image": "https://i.imgur.com/X17rXVy.png",
        "strength": "1",
        "W": 512,
        "H": 512,
        "seed": 2504314064,
        "steps": 30,
        "lora": ""
    }
}