Flux Schnell API Documentation

Use this Flux Schnell API Documentation to access a complete integration guide, featuring step-by-step instructions, code examples, and best practices. Follow this API doc to seamlessly integrate Flux Schnell's powerful features into your applications, transforming digital experiences and enhancing user engagement with ease.

Authentication:

To use this API, first subscribe and get a Subscription key, then include this key in the header of your request.

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/flux-1-schnell/v1/getData

Request Body

API Parameters: The API POST- https://gateway.appypie.com/flux-1-schnell/v1/getData takes the following parameters:

Parameter Required Type Description
prompt Yes string Prompts guide image generation by describing the desired content, such as, “a cozy mountain cabin under a starry night sky.”
num_steps Optional integer The number of diffusion steps; higher values can improve quality but take longer Default: 4, (maximum: 8)
seed Optional integer A value used to generate a consistent sequence of pseudo-random numbers, ensuring reproducibility in the image creation process.
height Optional integer Defines the desired height of the generated image in pixels. Default is 1024.
width Optional integer Specifies the desired width of the generated image in pixels. Default is 1024.

Example Request Body

JSON

{
    "prompt": "Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.",
    "num_steps": 4
    "seed": 15,
    "height": 512,
    "width": 512
}
  

Request Code

Input
 POST https://gateway.appypie.com/flux-1-schnell/v1/getData HTTP/1.1

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

{
    "prompt": "Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.",
    "num_steps": 4,
    "seed": 15,
    "height": 512,
    "width": 512
}
import urllib.request, json

try:
    url = "https://gateway.appypie.com/flux-1-schnell/v1/getData"

    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": "Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.",
    "num_steps": 4,
    "seed": 15,
    "height": 512,
    "width": 512
};

fetch('https://gateway.appypie.com/flux-1-schnell/v1/getData', {
        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/flux-1-schnell/v1/getData" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{
    \"prompt\": \"Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.\",
    \"num_steps\": 4,
    \"seed\": 15,
    \"height\": 512,
    \"width\": 512
}"
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/flux-1-schnell/v1/getData";
        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\": \"Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.\", \"num_steps\": 4, \"seed\": 15, \"height\": 512, \"width\": 512 }".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/flux-1-schnell/v1/getData";
$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": "Create a dynamic image of a female skateboarder executing a high-flying trick at the Paris Olympics, with iconic Paris landmarks like the Eiffel Tower in the background.",
    "num_steps": 4,
    "seed": 15,
    "height": 512,
    "width": 512
}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body);

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


Response

JSON


 HTTP/1.1 200 OK

{
    "output": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/flux-schnell-cf/prompt-1728386209914-87467.png"
}

  

Response Handling

The Flux Schnell API provides clear HTTP status codes and detailed response messages, indicating whether a request was processed successfully or if an error occurred. Implementing robust error handling is essential for developers to effectively interpret and manage these responses within their applications.

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 Flux Schnell API documentation offers all the essential information for effectively utilizing the Flux Schnell API. Be sure to replace YOUR_SUBSCRIPTION_KEY with the actual key you received when subscribing to the service, ensuring seamless integration and optimal performance in your applications.