SDXL Turbo API Documentation

Discover how to integrate SDXL Turbo's advanced image generation capabilities into your projects. This SDXL API documentation offers clear instructions, practical examples, and best practices, enabling you to effectively use SDXL Turbo on your applications.

Authentication:

To access this API, you must subscribe and get a Subscription Key. Include this key in the request header to authenticate and gain access.

Request Headers:

Content-Type Set to application/json
Cache-Control Recommended to set to no-cache
Ocp-Apim-Subscription-Key YOUR_SUBSCRIPTION_KEY

Endpoint

Base URL: https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage

Request Body

API Parameters: The API POST- https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage takes the following parameters:

Parameter Required Type Description
prompt Yes string Prompts provide direction for image generation by describing the desired content. For example, “a bustling city street at night, illuminated by neon signs and streetlights.”
negative_prompt No string Negative prompts are used to guide image generation by specifying what elements to avoid. For example, “Avoid using bright colors or including people in the background.”
height No Number, default 1024 The height in pixels of the generated image. This is set to 1024 by default for the best results. Anything below 512 pixels won’t work well.
width No Number, default 1024 The width in pixels of the generated image. This is set to 1024 by default for the best results.
num_inference_steps No Number, default 20, Maximum 20 The number of denoising steps. More denoising steps usually lead to a higher-quality image at the expense of slower inference.
guidance_scale No float, default 5.0 Guidance scale is enabled by setting guidance_scale > 1. A higher guidance scale encourages generating images closely linked to the text prompt, usually at the expense of lower image quality.
seed No 42 The seed is used to reproduce results. Providing the same seed will yield the same image each time. Use “null” for a random number seed.

Example Request Body

JSON

{
    "prompt": "Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.",
    "negative_prompt": "Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.",

    "height": 768,
    "width": 768,
    "num_inference_steps": 20,
    "guidance_scale": 5,
    "seed": 20
}

Request Code

Input
   
POST https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage HTTP/1.1

Content-Type: application/json
Cache-Control: no-cache

{
    "prompt": "Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.",
    "negative_prompt": "Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.",

    "height": 768,
    "width": 768,
    "num_inference_steps": 20,
    "guidance_scale": 5,
    "seed": 20
}
import urllib.request, json

try:
    url = "https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage"

    hdr ={
    # Request headers
    'Content-Type': 'application/json',
    'Cache-Control': 'no-cache',
    }

    # Request body
    data =  
    data = json.dumps(data)
    req = urllib.request.Request(url, headers=hdr, data = bytes(data.encode("utf-8")))

    req.get_method = lambda: 'POST'
    response = urllib.request.urlopen(req)
    print(response.getcode())
    print(response.read())
    except Exception as e:
    print(e)
                                    
// Request body
const body = {
    "prompt": "Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.",
    "negative_prompt": "Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.",

    "height": 768,
    "width": 768,
    "num_inference_steps": 20,
    "guidance_scale": 5,
    "seed": 20
}
;

fetch('https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage', {
        method: 'POST',
        body: JSON.stringify(body),
        // Request headers
        headers: {
            'Content-Type': 'application/json',
            'Cache-Control': 'no-cache',}
    })
    .then(response => {
        console.log(response.status);
        console.log(response.text());
    })
    .catch(err => console.error(err));
curl -v -X POST "https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{
    \"prompt\": \"Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.\",
    \"negative_prompt\": \"Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.\",
    \"height\": 768,
    \"width\": 768,
    \"num_inference_steps\": 20,
    \"guidance_scale\": 5,
    \"seed\": 20
}"
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.io.UnsupportedEncodingException;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.FileInputStream;

public class HelloWorld {

  public static void main(String[] args) {
    try {
        String urlString = "https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage";
        URL url = new URL(urlString);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        //Request headers
    connection.setRequestProperty("Content-Type", "application/json");
    
    connection.setRequestProperty("Cache-Control", "no-cache");
    
        connection.setRequestMethod("POST");

        // Request body
        connection.setDoOutput(true);
        connection
            .getOutputStream()
            .write(
             "{ \"prompt\": \"Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.\", \"negative_prompt\": \"Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.\", \"height\": 768, \"width\": 768, \"num_inference_steps\": 20, \"guidance_scale\": 5, \"seed\": 20 }".getBytes()
             );
    
        int status = connection.getResponseCode();
        System.out.println(status);

        BufferedReader in = new BufferedReader(
            new InputStreamReader(connection.getInputStream())
        );
        String inputLine;
        StringBuffer content = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            content.append(inputLine);
        }
        in.close();
        System.out.println(content);

        connection.disconnect();
    } catch (Exception ex) {
      System.out.print("exception:" + ex.getMessage());
    }
  }
}
$url = "https://gateway.appypie.com/sdxl/getImageTurbo/v1/SDXL_Turbo_TextImage";
$curl = curl_init($url);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

# Request headers
$headers = array(
    'Content-Type: application/json',
    'Cache-Control: no-cache',);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

# Request body
$request_body = '{
    "prompt": "Generate a detailed futuristic cityscape at sunset with towering skyscrapers, flying vehicles, and vibrant orange and purple skies. Blend modern architecture with natural elements like parks and flowing water, capturing a tranquil yet innovative atmosphere.",
    "negative_prompt": "Exclude low-quality, blurry, or pixelated details. Avoid dull colors, overly simplistic architecture, empty streets, or outdated technology. Omit any chaotic or disorganized elements, dark or gloomy tones, and unnatural lighting.",

    "height": 768,
    "width": 768,
    "num_inference_steps": 20,
    "guidance_scale": 5,
    "seed": 20
}
';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);


Response

JSON


HTTP/1.1 200 OK

{
    "imageUrl": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/sdxl/prompt-946938984-1728469931401-828639.png"
}

Response Handling

The SDXL Turbo API returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement proper error handling in their applications to manage these responses effectively.

Common Status Codes and Responses

Status Code Description Response Body
200 Success - The request was successfully processed, and the image generation is in progress or completed. { "msg": "Image Getting Created", ... }
400 Bad Request - The request contains invalid parameters or missing fields. { "error": "Invalid request parameters" }
401 Unauthorized - The provided subscription key is missing or invalid. { "error": "Invalid or missing authentication" }
403 Forbidden - The subscription does not have access to this API or action. { "error": "Access denied for this operation" }
404 Not Found - The requested resource or endpoint could not be found. { "error": "Endpoint not found" }
429 Too Many Requests - The request rate limit has been exceeded. { "error": "Rate limit exceeded, please retry later" }
500 Internal Server Error - An unexpected error occurred on the server. { "error": "An unexpected error occurred, please try again later" }

Example Error Response

{
    "error": "Invalid prompt parameter"
}

Conclusion

This documentation provides all the essential information for effectively using the SDXL Turbo API. Be sure to replace YOUR_API_KEY with the actual key you received when subscribing to the service.