Stable Diffusion 3.5
Text to image with Stable Diffusion 3.5
- Python
- JavaScript
- PHP
import requests
import json
url = "https://api.imagepipeline.io/sd3_5/v1"
headers = {
"API-Key": "Your API Key",
"Content-Type": "application/json"
}
data = {
"prompt": "beautiful waterfall in the rainforest, anime style",
"negative_prompt": "error, cropped, worst quality, low quality, duplicate, bad proportions, incomplete subject",
"num_inference_steps": 4,
"samples": 1,
"guidance_scale":0.0,
"width": 1024,
"height": 1024
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = "https://api.imagepipeline.io/sd3_5/v1";
const headers = {
"API-Key": "Your API Key",
"Content-Type": "application/json"
};
const data = {
"prompt": "beautiful waterfall in the rainforest, anime style",
"negative_prompt": "error, cropped, worst quality, low quality, duplicate, bad proportions, incomplete subject",
"num_inference_steps": 4,
"samples": 1,
"guidance_scale":0.0,
"width": 1024,
"height": 1024
};
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_5/v1";
$headers = array(
"API-Key: Your-API-Key",
"Content-Type: application/json"
);
$data = array(
"prompt"=> "beautiful waterfall in the rainforest, anime style",
"negative_prompt"=> "error, cropped, worst quality, low quality, duplicate, bad proportions, incomplete subject",
"num_inference_steps"=> 4,
"samples"=> 1,
"guidance_scale"=> 0.0,
"width"=> 1024,
"height"=> 1024
);
$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: 2 . 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_5/v1/status/{{id}}
Pass the API-Key as the authorization in the header.