Flux Dev API Documentation
Text To Image - Request Code
POST https://gateway.pixazo.ai/flux-dev/v1/dev/textToImage Content-Type: application/json Cache-Control: no-cache Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY { "prompt": "A sunset over a mountain range", "image_size": "landscape_4_3" } import requests url = "https://gateway.pixazo.ai/flux-dev/v1/dev/textToImage" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache", "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY" } data = { "prompt": "A sunset over a mountain range", "image_size": "landscape_4_3" } response = requests.post(url, json=data, headers=headers) print(response.json()) const url = 'https://gateway.pixazo.ai/flux-dev/v1/dev/textToImage'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY' }; const body = { prompt: 'A sunset over a mountain range', image_size: 'landscape_4_3' }; fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(body) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); curl -v -X POST "https://gateway.pixazo.ai/flux-dev/v1/dev/textToImage" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \ --data-raw '{ "prompt": "A sunset over a mountain range", "image_size": "landscape_4_3" }' 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-dev/v1/dev/textToImage"; String json = """ { "prompt": "A sunset over a mountain range", "image_size": "landscape_4_3" } """; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .timeout(Duration.ofSeconds(10)) .header("Content-Type", "application/json") .header("Cache-Control", "no-cache") .header("Ocp-Apim-Subscription-Key", "YOUR_SUBSCRIPTION_KEY") .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } <?php $ch = curl_init(); $url = 'https://gateway.pixazo.ai/flux-dev/v1/dev/textToImage'; $data = json_encode([ 'prompt' => 'A sunset over a mountain range', 'image_size' => 'landscape_4_3' ]); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Cache-Control: no-cache', 'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?> Output
Successful API response:
{ "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } Request Body - Text To Image
Parameters for /dev/textToImage:
| Parameter | Required | Type | Description |
|---|---|---|---|
| prompt | Yes | string | The instruction or description for the image to be generated |
| image_size | No | string | The aspect ratio of the generated image, Possible enum values: square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, landscape_16_9 |
| num_inference_steps | No | integer | The number of denoising steps. Higher values result in higher quality images but take longer to generate |
| guidance_scale | No | float | Controls how closely the model follows the prompt. Higher values make the model adhere more closely to the prompt |
| num_images | No | integer | The number of images to generate |
| enable_safety_checker | No | boolean | Whether to enable the safety checker to filter NSFW content |
| output_format | No | string | The format of the generated image. Values: "jpeg", "png" |
| acceleration | No | string | The speed of generation. Values: "none", "regular", "high" |
Example Request - Text To Image
JSON
{ "prompt": "A sunset over a mountain range", "image_size": "landscape_4_3" } Response - Text To Image
JSON
{ "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } Request Headers
| Header | Description |
|---|---|
| Content-Type | Must be set to application/json |
| Cache-Control | Must be set to no-cache |
| Ocp-Apim-Subscription-Key | Your API subscription key for authentication |
Response Handling
The flux Dev 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-dev-polling/dev/getFluxDevStatus
Request Body
{ "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } POST https://gateway.pixazo.ai/flux-dev-polling/dev/getFluxDevStatus Content-Type: application/json Cache-Control: no-cache { "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } import requests url = "https://gateway.pixazo.ai/flux-dev-polling/dev/getFluxDevStatus" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache" } data = { "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } response = requests.post(url, json=data, headers=headers) print(response.json()) const url = 'https://gateway.pixazo.ai/flux-dev-polling/dev/getFluxDevStatus'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache' }; const body = { request_id: '0c22795e-5440-4e11-92d3-e5d967755d09' }; fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(body) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); curl -v -X POST "https://gateway.pixazo.ai/flux-dev-polling/dev/getFluxDevStatus" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ --data-raw '{ "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" }' 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-dev-polling/dev/getFluxDevStatus"; String json = """ { "request_id": "0c22795e-5440-4e11-92d3-e5d967755d09" } """; HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .timeout(Duration.ofSeconds(10)) .header("Content-Type", "application/json") .header("Cache-Control", "no-cache") .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } <?php $ch = curl_init(); $url = 'https://gateway.pixazo.ai/flux-dev-polling/dev/getFluxDevStatus'; $data = json_encode([ 'request_id' => '0c22795e-5440-4e11-92d3-e5d967755d09' ]); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Cache-Control: no-cache' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?> Example Success Response
{ "images": [{ "url": "https://storage.example.com/image-abc123.jpg", "width": 1024, "height": 768, "content_type": "image/jpeg" }], "timings": { "inference": 1.2312185550108552 }, "seed": 1551468471, "has_nsfw_concepts": [false], "prompt": "A sunset over a mountain range" } Flux Dev API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $0.025 |