Access the complete Stable Diffusion 3 API integration guide here. It features detailed step-by-step instructions, code examples, and best practices for integrating SD3's powerful features into your applications, effortlessly transforming digital experiences and boosting user engagement.
To use the SD3 API, subscribe and receive a Subscription Key. Add this key to your request header for authentication, ensuring proper access to the API.
Content-Type | Set to application/json |
---|---|
Cache-Control | Recommended to set to no-cache |
Ocp-Apim-Subscription-Key | YOUR_SUBSCRIPTION_KEY |
Base URL: https://gateway.appypie.com/sd3/v1/getData
API Parameters: The API POST- https://gateway.appypie.com/sd3/v1/getData takes the following parameters:
Parameter | Required | Type | Description |
prompt | Required | string | The text query that instructs the AI model on what content to generate. Example: "women's street skateboarding final in Paris Olympics 2024." |
negativePrompt | Optional | string | Negative prompts do not work reliably in SD3. Using a negative prompt may alter the output in unpredictable ways. |
steps | Optional | integer | The number of steps for the transformation process. Default: 28 (minimum: 1, maximum: 28). |
cfg | Optional | decimal | The guidance scale determines how closely the output should match the prompt. Default: 3.5 (minimum: 0, maximum: 20). |
aspect_ratio | Optional | string | The aspect ratio of the output image. This value is ignored if an input image is provided. Default: "1:1". |
output_format | Optional | string | The format of the output images. Default: "webp." |
output_quality | Optional | integer | The quality of the output images, ranging from 0 to 100. Higher values indicate better quality. Default: 90 (minimum: 0, maximum: 100). |
prompt_strength | Optional | decimal | The strength of the prompt (or denoising strength) when using image-to-image. A value of 1.0 results in full destruction of the input image information. Default: 0.85 (minimum: 0, maximum: 1). |
JSON
{ "prompt": "Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.", "negativePrompt": "dark, blurry", "steps": 28, "cfg": 4, "aspect_ratio": "3:2", "output_format": "jpg", "output_quality": 90, "prompt_strength": 0.85 }
POST https://gateway.appypie.com/sd3/v1/getData HTTP/1.1 Content-Type: application/json Cache-Control: no-cache { "prompt": "Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.", "negativePrompt": "dark, blurry", "steps": 28, "cfg": 4, "aspect_ratio": "3:2", "output_format": "jpg", "output_quality": 90, "prompt_strength": 0.85 }
import urllib.request, json try: url = "https://gateway.appypie.com/sd3/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": "Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.", "negativePrompt": "dark, blurry", "steps": 28, "cfg": 4, "aspect_ratio": "3:2", "output_format": "jpg", "output_quality": 90, "prompt_strength": 0.85 }; fetch('https://gateway.appypie.com/sd3/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/sd3/v1/getData" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{ \"prompt\": \"Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.\", \"negativePrompt\": \"dark, blurry\", \"steps\": 28, \"cfg\": 4, \"aspect_ratio\": \"3:2\", \"output_format\": \"jpg\", \"output_quality\": 90, \"prompt_strength\": 0.85 }"
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/sd3/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\": \"Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.\", \"negativePrompt\": \"dark, blurry\", \"steps\": 28, \"cfg\": 4, \"aspect_ratio\": \"3:2\", \"output_format\": \"jpg\", \"output_quality\": 90, \"prompt_strength\": 0.85 }".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/sd3/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": "Picture a sleek, futuristic car racing through a neon-lit cityscape, its engine humming efficiently as it blurs past digital billboards. The driver skillfully navigates the glowing streets, aiming for victory in this high-tech, adrenaline-fueled race of tomorrow.", "negativePrompt": "dark, blurry", "steps": 28, "cfg": 4, "aspect_ratio": "3:2", "output_format": "jpg", "output_quality": 90, "prompt_strength": 0.85 }'; curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body); $resp = curl_exec($curl); curl_close($curl); var_dump($resp);
JSON
HTTP/1.1 200 OK { "output": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/SD3/prompt-1729769047650-227691.jpg" }
The SD3 API provides clear HTTP status codes and detailed response messages, indicating whether a request was successful or if an error occurred. Implementing robust error handling is crucial for developers to accurately interpret and manage these responses within their applications.
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" } |
{ "error": "Invalid prompt parameter" }
This SD3 API documentation provides all the necessary details for effectively using the SD3 API. Ensure you replace YOUR_SUBSCRIPTION_KEY with the actual key provided upon subscribing to the service, allowing for smooth integration and maximum performance in your applications.