GoAPI
Search
K
Comment on page

Stable Diffusion API

Integrate stable diffusion API into your applications!
Using our Stable Diffusion API helps you generate images without the need for:
  1. 1.
    an expensive desktop computer with high-end GPUs
  2. 2.
    deploying Automatic 1111 WebUI locally
  3. 3.
    downloading checkpoint and/or LoRA models
You can using 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 or Huggingface or your own models, please contact us using the form on our website.
Images processed via the Stable Diffusion API are stored for 7 days post-processing for user downloads. Please download any necessary images within this period.

Available Endpoints

post
https://api.midjourneyapi.xyz
/sd/txt2img
Text-to-image
The text-to-image endpoint from our Stable Diffusion API generates an image from a text prompt. This endpoint most of the time 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
X-API-KEY*
string
Your API Key used for request authorization
Body
model_id
string
The ID of the checkpoints model to be used, any available public models in Civitai
prompt
string
Text prompt with description of the the things you want in the image to be generated
negative_prompt
string
Text prompt with description of the things you don’t want in the image to be generated
width
string
Horizontal resolution, maximum: 1024
height
string
Vertical resolution, maximum: 1024
seed
integer
A numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_model
string
Multi lora is supported, pass comma saparated lora_model_id. Example: moxin, contrast-fix
lora_strength
float
Controls how much the checkpoint model fin-tuned by the lora
num_inference_steps
string
the number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scale
float
a 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.
Responses
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

Python
Node
Curl
import requests
X_API_KEY = "YOUR_API_KEY"
endpoint = "https://api.midjourneyapi.xyz/sd/txt2img"
headers = {
"X-API-KEY": X_API_KEY
}
data = {
"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": None,
"lora_model": None,
"lora_strength": None
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
const axios = require('axios');
const X_API_KEY = "YOUR_API_KEY";
const endpoint = "https://api.midjourneyapi.xyz/sd/txt2img";
const headers = {
"X-API-KEY": X_API_KEY
};
const data = {
"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
};
axios.post(endpoint, data, { headers })
.then(response => {
console.log(response.status);
console.log(response.data);
})
.catch(error => {
console.error(error);
});
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": ""
}
}
post
https://api.midjourneyapi.xyz
/sd/img2img
Image-to-Image Endpoint
The image-to-image endpoint from our Stable Diffusion API 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
X-API-KEY*
string
Your API Key used for request authorization
Body
model_id
string
The ID of the checkpoints model to be used, any available public models in Civitai
prompt
string
Text prompt with description of the the things you want in the image to be generated
negative_prompt
string
Text prompt with description of the things you don’t want in the image to be generated
init_image
string
URL link to the initial image
strength
float
Prompt strength when using init image, 1.0 corresponds to full destruction of information in the init image
width
string
Horizontal resolution, maximum: 1024
height
string
Vertical resolution, maximum: 1024
seed
string
A numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_model
string
Multi lora is supported, pass comma saparated lora_model_id. Example: moxin, contrast-fix
lora_strength
float
Controls how much the checkpoint model fin-tuned by the lora
num_inference_steps
string
the number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scale
float
a 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.
Responses
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

Python
Node
Curl
import requests
X_API_KEY = "YOUR_API_KEY"
endpoint = "https://api.midjourneyapi.xyz/sd/img2img"
headers = {
"X-API-KEY": X_API_KEY
}
data = {
"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": None,
"lora_model": None,
"lora_strength": None
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
const axios = require('axios');
const X_API_KEY = "YOUR_API_KEY";
const endpoint = "https://api.midjourneyapi.xyz/sd/img2img";
const headers = {
"X-API-KEY": X_API_KEY
};
const data = {
"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-
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": ""
}
}
post
https://api.midjourneyapi.xyz
/sd/fetch
Fetch
The fetch endpoint from our Stable Diffusion API 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
id*
integer
Returned by the id parameter in the response upon generation request
Responses
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

Python
Node
Curl
import requests
endpoint = "https://api.midjourneyapi.xyz/sd/fetch"
data = {
"id": 30588303
}
response = requests.post(endpoint, json=data)
print(response.status_code)
print(response.json())
const axios = require('axios');
const endpoint = 'https://api.midjourneyapi.xyz/sd/fetch';
const data = {
id: 30588303,
};
axios
.post(endpoint, data)
.then((response) => {
console.log(response.status);
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
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"
}
post
https://api.midjourneyapi.xyz
/sd/upscale
Upscale
The upscale endpoint from our Stable Diffusion API returns the corresponding upscaled image of the image passed.
Parameters
Header
X-API-KEY*
string
Returned by the task_id parameter in the response upon an image generation request
Body
url*
string
URL of the image that you want to upscale
scale
integer
A number for scaling the image
Responses
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

Example Request

Python
Node
Untitled
import requests
X_API_KEY = "YOUR_API_KEY"
endpoint = "https://api.midjourneyapi.xyz/sd/upscale"
headers = {
"X-API-KEY": X_API_KEY
}
data = {
"url": "https://img.midjourneyapi.xyz/sd/0-77b8a8cf-c624-435f-95f2-482c041c3fa6.png",
"scale": 2
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
const axios = require('axios');
const X_API_KEY = 'YOUR_API_KEY';
const endpoint = 'https://api.midjourneyapi.xyz/sd/upscale';
const headers = {
'X-API-KEY': X_API_KEY,
};
const data = {
url: 'https://img.midjourneyapi.xyz/sd/0-77b8a8cf-c624-435f-95f2-482c041c3fa6.png',
scale: 2,
};
axios
.post(endpoint, data, { headers })
.then((response) => {
console.log(response.status);
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
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"

Example Response

{
"generationTime": 7.332714319229126,
"id": 30591185,
"output": "https://cdn.stablediffusionapi.com/generations/1690188415_out.png",
"status": "success"
}
post
https://api.midjourneyapi.xyz
/sd/controlnet
ControlNet Endpoint
The controlnet endpoint from our Stable Diffusion API 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
X-API-KEY*
string
Returned by the task_id parameter in the response upon an image generation request
Body
model_id*
string
The ID of the checkpoints model to be used, any available public models in Civitai
prompt
string
Text prompt with description of the the things you want in the image to be generated
negative_prompt
string
Text prompt with description of the things you don’t want in the image to be generated
width
string
Horizontal resolution, maximum: 1024
height
string
Vertical resolution, maximum: 1024
seed
integer
A numerical value used by Diffusion algorithm to generate image, Pass null for a random number as seed
lora_model
string
Multi lora is supported, pass comma saparated lora_model_id. Example: moxin, contrast-fix
lora_strength
float
Controls how much the checkpoint model fin-tuned by the lora
init_image*
string
URL link to the initial image
strength
float
Prompt strength when using init image, 1.0 corresponds to full destruction of information in the init image
controlnet_type
string
The type of controlnet preprocessor
controlnet_model*
string
The ID of the controlnet model to be used
control_image
string
URL link to the image used by controlnet
controlnet_conditioning_scale
float
Scale for controlnet guidance (minimum: 1; maximum: 20)
num_inference_steps
string
the number of denoising steps to be performed. Accepted values are 21, 31, 41, and 51.
guidance_scale
float
a 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.
Responses
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

Python
Node
Curl
import requests
X_API_KEY = "YOUR_API_KEY"
endpoint = "https://api.midjourneyapi.xyz/sd/controlnet"
headers = {
"X-API-KEY": X_API_KEY
}
data = {
"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,
"seed": None,
"lora_model": None,
"lora_strength": None
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
const axios = require('axios');
const X_API_KEY = 'YOUR_API_KEY';
const endpoint = 'https://api.midjourneyapi.xyz/sd/controlnet';
const headers = {
'X-API-KEY': X_API_KEY,
};
const data = {
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,
};
axios
.post(endpoint, data, { headers })
.then((response) => {
console.log(response.status);
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
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": ""
}
}
Last modified 10d ago