Stable Diffusion 3
Text to image with Stable Diffusion 3
- Python
- JavaScript
- PHP
import requests
import json
url = "https://api.imagepipeline.io/sd3/v1"
headers = {
"API-Key": "Your API Key",
"Content-Type": "application/json"
}
data = {
"samples": 2,
"prompt": "High end wildlife photography, beautiful colourful toucan sitting on a tree branch, trending on artstation",
"negative_prompt": "censored, worst quality, normal quality, low quality, low res, blurry, distorted facial, missing eyes, distorted eyes, distorted nose, bad mouth, watermark, weird faces, extra digits, cropped, jpeg artifacts, signature, username, error, sketch, duplicate, ugly, monochrome, horror, geometry, mutation, disgusting, low resolution",
"guidance_scale": 7,
"width": 1024,
"height": 1024,
"num_inference_steps": 29
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = "https://api.imagepipeline.io/sd3/v1";
const headers = {
"API-Key": "Your API Key",
"Content-Type": "application/json"
};
const data = {
"samples": 2,
"prompt": "High end wildlife photography, beautiful colourful toucan sitting on a tree branch, trending on artstation",
"negative_prompt": "censored, worst quality, normal quality, low quality, low res, blurry, distorted facial, missing eyes, distorted eyes, distorted nose, bad mouth, watermark, weird faces, extra digits, cropped, jpeg artifacts, signature, username, error, sketch, duplicate, ugly, monochrome, horror, geometry, mutation, disgusting, low resolution",
"guidance_scale": 7,
"width": 1024,
"height": 1024,
"num_inference_steps": 29
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch((error) => console.error('Error:', error));
<?php
$url = "https://api.imagepipeline.io/sd3/v1";
$headers = array(
"API-Key: Your-API-Key",
"Content-Type: application/json"
);
$data = array(
"samples" => 2,
"prompt" => "High end wildlife photography, beautiful colourful toucan sitting on a tree branch, trending on artstation",
"negative_prompt" => "censored, worst quality, normal quality, low quality, low res, blurry, distorted facial, missing eyes, distorted eyes, distorted nose, bad mouth, watermark, weird faces, extra digits, cropped, jpeg artifacts, signature, username, error, sketch, duplicate, ugly, monochrome, horror, geometry, mutation, disgusting, low resolution",
"guidance_scale" => 7,
"width" => 1024,
"height" => 1024,
"num_inference_steps" => 29
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if($response === FALSE){
die(curl_error($ch));
}
$responseData = json_decode($response, TRUE);
curl_close($ch);
var_dump($responseData);
?>
Available JSON Parameters for Control
Parameter | Type | Notes |
---|---|---|
prompt | string | Required. Description of the image to generate. |
negative_prompt | string | Required. Description of what should not appear in the image. |
num_inference_steps | integer | Required. Number of inference steps. |
samples | integer | Required. Max: 4 . Number of images to generate. |
guidance_scale | number | Required. Max: 20 . Controls how much the image should adhere to the prompt. |
height | integer | Default: 1024 . Optional image height. |
width | integer | Default: 1024 . Optional image width. |
webhook | string | Generated image will be sent to this webhook. |
direct_link | boolean | Fetches the friendly URL in PNG format. |
batch_id | string | Adds a batch_id. |
file_prefix | string | Adds a file_prefix. |
queued_image_urls | boolean | Returns the links of the images prematurely. The link will have the image once the task is completed. |
Status
Your response will include a status
.
- If the
status
=SUCCESS
, you will also havedownload_urls
that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 4. - If the
status
=PENDING
, you will receive anid
. You can use the status endpoint to fetch your image using theid
. - If the
status
=FAILURE
, you will receive only an error message.
Endpoint: [GET]
https://api.imagepipeline.io/sd3/v1/status/{{id}}
Pass the API-Key as the authorization in the header.