Flux.1-dev ControlNet API Documentation
Generate Text To Image Request - Request Code
POST https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest Content-Type: application/json Cache-Control: no-cache Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY { "prompt": "A futuristic city under a starry sky", "num_inference_steps": 28, "image_size": "landscape_16_9", "seed": 42, "negative_prompt": "blur", "guidance_scale": 3.5, "real_cfg_scale": 3.5, "num_images": 1, "enable_safety_checker": true, "reference_strength": 0.65, "reference_end": 1, "base_shift": 0.5, "max_shift": 1.15, "output_format": "png", "scheduler": "euler", "nag_scale": 3, "nag_tau": 2.5, "nag_alpha": 0.25, "nag_end": 0.25 } import requests import json url = "https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache", "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY" } data = { "prompt": "A futuristic city under a starry sky", "num_inference_steps": 28, "image_size": "landscape_16_9", "seed": 42, "negative_prompt": "blur", "guidance_scale": 3.5, "real_cfg_scale": 3.5, "num_images": 1, "enable_safety_checker": true, "reference_strength": 0.65, "reference_end": 1, "base_shift": 0.5, "max_shift": 1.15, "output_format": "png", "scheduler": "euler", "nag_scale": 3, "nag_tau": 2.5, "nag_alpha": 0.25, "nag_end": 0.25 } response = requests.post(url, headers=headers, data=json.dumps(data)) print(response.json()) const url = 'https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY' }; const data = { prompt: 'A futuristic city under a starry sky', num_inference_steps: 28, image_size: 'landscape_16_9', seed: 42, negative_prompt: 'blur', guidance_scale: 3.5, real_cfg_scale: 3.5, num_images: 1, enable_safety_checker: true, reference_strength: 0.65, reference_end: 1, base_shift: 0.5, max_shift: 1.15, output_format: 'png', scheduler: 'euler', nag_scale: 3, nag_tau: 2.5, nag_alpha: 0.25, nag_end: 0.25 }; 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)); curl -v -X POST "https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \ --data-raw '{ "prompt": "A futuristic city under a starry sky", "num_inference_steps": 28, "image_size": "landscape_16_9", "seed": 42, "negative_prompt": "blur", "guidance_scale": 3.5, "real_cfg_scale": 3.5, "num_images": 1, "enable_safety_checker": true, "reference_strength": 0.65, "reference_end": 1, "base_shift": 0.5, "max_shift": 1.15, "output_format": "png", "scheduler": "euler", "nag_scale": 3, "nag_tau": 2.5, "nag_alpha": 0.25, "nag_end": 0.25 }' import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; public class Main { public static void main(String[] args) throws Exception { String url = "https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest"; String json = """ { "prompt": "A futuristic city under a starry sky", "num_inference_steps": 28, "image_size": "landscape_16_9", "seed": 42, "negative_prompt": "blur", "guidance_scale": 3.5, "real_cfg_scale": 3.5, "num_images": 1, "enable_safety_checker": true, "reference_strength": 0.65, "reference_end": 1, "base_shift": 0.5, "max_shift": 1.15, "output_format": "png", "scheduler": "euler", "nag_scale": 3, "nag_tau": 2.5, "nag_alpha": 0.25, "nag_end": 0.25 } """; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Content-Type", "application/json") .header("Cache-Control", "no-cache") .header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY") .timeout(Duration.ofSeconds(10)) .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } <?php $url = 'https://gateway.pixazo.ai/flux-general/v1/flux-general/generateTextToImageRequest'; $headers = [ 'Content-Type: application/json', 'Cache-Control: no-cache', 'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY' ]; $data = [ 'prompt' => 'A futuristic city under a starry sky', 'num_inference_steps' => 28, 'image_size' => 'landscape_16_9', 'seed' => 42, 'negative_prompt' => 'blur', 'guidance_scale' => 3.5, 'real_cfg_scale' => 3.5, 'num_images' => 1, 'enable_safety_checker' => true, 'reference_strength' => 0.65, 'reference_end' => 1, 'base_shift' => 0.5, 'max_shift' => 1.15, 'output_format' => 'png', 'scheduler' => 'euler', 'nag_scale' => 3, 'nag_tau' => 2.5, 'nag_alpha' => 0.25, 'nag_end' => 0.25 ]; $payload = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?> Output
Successful API response:
{ "request_id": "req_abc123xyz" } Request Body - Generate Text To Image Request
Parameters for /flux-general/generateTextToImageRequest:
| Parameter | Required | Type | Description |
|---|---|---|---|
| prompt | Yes | string | Default: null, The prompt to generate an image from. A versatile endpoint that supports multiple AI extensions including LoRA, ControlNet conditioning, and IP-Adapter integration |
| image_size | Optional | string | Default: null, The size of the generated image. Values: "square_hd", "square", "portrait_4_3", "portrait_16_9", "landscape_4_3", "landscape_16_9" |
| num_inference_steps | Optional | integer | Default: 28, The number of inference steps to perform. Higher values result in higher quality images but take longer to generate |
| seed | Optional | integer | Default: null, The same seed and prompt will output the same image every time |
| loras | Optional | array | Default: [], The LoRAs to use for image generation. Multiple LoRAs can be merged together |
| control_loras | Optional | array | Default: [], The LoRAs to use for image generation which use a control image |
| controlnets | Optional | array | Default: [], The controlnets to use for image generation. Only one controlnet is supported |
| controlnet_unions | Optional | array | Default: [], The controlnet unions to use for image generation. Only one controlnet is supported |
| ip_adapters | Optional | array | Default: [], IP-Adapter to use for image generation |
| easycontrols | Optional | array | Default: [], EasyControl Inputs to use for image generation |
| guidance_scale | Optional | float | Default: 3.5, Controls how closely the model follows the prompt |
| real_cfg_scale | Optional | float | Default: 3.5, The CFG scale for how closely the model sticks to your prompt |
| num_images | Optional | integer | Default: 1, The number of images to generate |
| enable_safety_checker | Optional | boolean | Default: true, Whether to enable the safety checker |
| reference_strength | Optional | float | Default: 0.65, Strength of reference-only generation. Only used if reference image is provided |
| reference_end | Optional | float | Default: 1, The percentage of timesteps when reference guidance ends |
| base_shift | Optional | float | Default: 0.5, Base shift for the scheduled timesteps |
| max_shift | Optional | float | Default: 1.15, Max shift for the scheduled timesteps |
| output_format | Optional | string | Default: "png", The format of the generated image. Values: "jpeg", "png" |
| scheduler | Optional | string | Default: "euler", Scheduler for the denoising process. Values: "euler", "dpmpp_2m" |
| negative_prompt | Optional | string | Default: "", Negative prompt to steer generation away from unwanted features |
| nag_scale | Optional | float | Default: 3, The scale for NAG. Higher values make image more distant from negative prompt |
| nag_tau | Optional | float | Default: 2.5, The tau for NAG. Controls hidden state normalization |
| nag_alpha | Optional | float | Default: 0.25, The alpha value for NAG. Final weighting factor for steering normalized guidance |
| nag_end | Optional | float | Default: 0.25, The proportion of steps to apply NAG |
Example Request - Generate Text To Image Request
JSON
{ "prompt": "A futuristic city under a starry sky", "num_inference_steps": 28, "image_size": "landscape_16_9", "seed": 42, "negative_prompt": "blur", "guidance_scale": 3.5, "real_cfg_scale": 3.5, "num_images": 1, "enable_safety_checker": true, "reference_strength": 0.65, "reference_end": 1, "base_shift": 0.5, "max_shift": 1.15, "output_format": "png", "scheduler": "euler", "nag_scale": 3, "nag_tau": 2.5, "nag_alpha": 0.25, "nag_end": 0.25 } Response - Generate Text To Image Request
JSON
{ "request_id": "req_abc123xyz" } Request Headers
| Header | Description |
|---|---|
| Content-Type | application/json |
| Cache-Control | no-cache |
| Ocp-Apim-Subscription-Key | API subscription key for authentication |
Response Handling
The Flux General returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement 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. | { "success": true, ... } |
| 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 parameters" } Retrieving Image Result and URL
After submitting your request, use this endpoint to check status and retrieve results.
Endpoint
POST https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus
Request Body
{ "request_id": "req_abc123xyz" } Code Examples
POST https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus Content-Type: application/json Cache-Control: no-cache Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY { "request_id": "req_abc123xyz" } import requests import json url = "https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache", "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY" } data = { "request_id": "req_abc123xyz" } response = requests.post(url, headers=headers, data=json.dumps(data)) print(response.json()) const url = 'https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY' }; const data = { request_id: 'req_abc123xyz' }; 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)); curl -v -X POST "https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \ --data-raw '{ "request_id": "req_abc123xyz" }' import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; public class Main { public static void main(String[] args) throws Exception { String url = "https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus"; String json = """ { "request_id": "req_abc123xyz" } """; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Content-Type", "application/json") .header("Cache-Control", "no-cache") .header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY") .timeout(Duration.ofSeconds(10)) .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } <?php $url = 'https://gateway.pixazo.ai/flux-general-polling/flux-general/getStatus'; $headers = [ 'Content-Type: application/json', 'Cache-Control: no-cache', 'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY' ]; $data = [ 'request_id' => 'req_abc123xyz' ]; $payload = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?> Example Success Response
{ "images": [ { "url": "https://storage.pixazo.ai/images/abc123.jpg", "width": 1024, "height": 768, "content_type": "image/jpeg" } ], "timings": { "inference": 1.2312185550108552 }, "seed": 1551468471, "has_nsfw_concepts": [ false ], "prompt": "A futuristic city under a starry sky" } Flux.1-dev ControlNet API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $0.09 |