FLUX Pro API Documentation
Text To Image - Request Code
POST https://gateway.pixazo.ai/flux-pro/v1/pro/textToImage HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"prompt": "A beautiful sunset over a mountain lake",
"image_size": "landscape_4_3"
} import requests
import json
url = "https://gateway.pixazo.ai/flux-pro/v1/pro/textToImage"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"prompt": "A beautiful sunset over a mountain lake",
"image_size": "landscape_4_3"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = 'https://gateway.pixazo.ai/flux-pro/v1/pro/textToImage';
const data = {
prompt: 'A beautiful sunset over a mountain lake',
image_size: 'landscape_4_3'
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
},
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-pro/v1/pro/textToImage" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
--data-raw '{
"prompt": "A beautiful sunset over a mountain lake",
"image_size": "landscape_4_3"
}'
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/flux-pro/v1/pro/textToImage";
String json = "{" +
"\n \"prompt\": \"A beautiful sunset over a mountain lake\"," +
"\n \"image_size\": \"landscape_4_3\"" +
"\n}";
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")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = 'https://gateway.pixazo.ai/flux-pro/v1/pro/textToImage';
$data = [
'prompt' => 'A beautiful sunset over a mountain lake',
'image_size' => 'landscape_4_3'
];
$json_data = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cache-Control: no-cache',
'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?> Output
Successful API response:
{
"request_id": "abc123-def456"
} Request Body - Text To Image
Parameters for /pro/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" |
Example Request - Text To Image
JSON
{
"prompt": "A beautiful sunset over a mountain lake",
"image_size": "landscape_4_3"
} Response - Text To Image
JSON
{
"request_id": "abc123-def456"
} 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 Pro 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-pro-polling/pro/getFluxProStatus
Request Body
{ "request_id": "abc123-def456" } POST https://gateway.pixazo.ai/flux-pro-polling/pro/getFluxProStatus HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"request_id": "abc123-def456"
} import requests
import json
url = "https://gateway.pixazo.ai/flux-pro-polling/pro/getFluxProStatus"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"request_id": "abc123-def456"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = 'https://gateway.pixazo.ai/flux-pro-polling/pro/getFluxProStatus';
const data = {
request_id: 'abc123-def456'
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
},
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-pro-polling/pro/getFluxProStatus" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
--data-raw '{
"request_id": "abc123-def456"
}'
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/flux-pro-polling/pro/getFluxProStatus";
String json = "{" +
"\n \"request_id\": \"abc123-def456\"" +
"\n}";
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")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = 'https://gateway.pixazo.ai/flux-pro-polling/pro/getFluxProStatus';
$data = [
'request_id' => 'abc123-def456'
];
$json_data = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cache-Control: no-cache',
'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?> FLUX Pro API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $0.06 |
Ready to generate FLUX Pro API assets?
Start with an API key, then automate your pipeline.