FLUX.2 Trainer API Documentation
Generate Request - Request Code
POST https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"image_data_url": "https://example.com/dataset.zip",
"steps": 1500,
"learning_rate": 0.00003
} import requests
url = "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"image_data_url": "https://example.com/dataset.zip",
"steps": 1500,
"learning_rate": 0.00003
}
response = requests.post(url, json=data, headers=headers)
print(response.json()) const url = 'https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request';
const data = {
image_data_url: 'https://example.com/dataset.zip',
steps: 1500,
learning_rate: 0.00003
};
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 -X POST "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
--data-raw '{
"image_data_url": "https://example.com/dataset.zip",
"steps": 1500,
"learning_rate": 0.00003
}' 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 ApiExample {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request";
String json = "{\n" +
" \"image_data_url\": \"https://example.com/dataset.zip\",\n" +
" \"steps\": 1500,\n" +
" \"learning_rate\": 0.00003\n" +
"}";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
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-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request';
$data = [
'image_data_url' => 'https://example.com/dataset.zip',
'steps' => 1500,
'learning_rate' => 0.00003
];
$json = 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);
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:
{ "status": "IN_QUEUE", "request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8", "message": "Training job queued for execution." } Request Body - Generate Request
Parameters for https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request:
| Parameter | Required | Type | Description |
|---|---|---|---|
| image_data_url | Yes | string | Base64-encoded URL or HTTP(S) endpoint pointing to a dataset of training images (PNG/JPG). Must include multiple samples (minimum 10 recommended) to train a robust LoRA model. |
| steps | Optional | integer | Number of training steps to perform. Higher values improve model quality but increase training time. |
| learning_rate | Optional | number | Learning rate for the LoRA adapter training process. Lower values ensure stable convergence; higher values may speed up training but risk instability. |
Example Request - Generate Request
JSON
{ "image_data_url": "https://example.com/dataset.zip", "steps": 1500, "learning_rate": 0.00003 } Response - Generate Request
JSON
{ "status": "IN_QUEUE", "request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8", "message": "Training job queued for execution." } 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 subscription key for authentication |
Response Handling
The flux 2 pro Text to Image Trainer 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 Results
After submitting your request, use this endpoint to check status and retrieve results.
Endpoint
POST https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result
Request Body
{ "request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8" } POST https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result HTTP/1.1
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
{
"request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"
} import requests
url = "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result"
headers = {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
"request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"
}
response = requests.post(url, json=data, headers=headers)
print(response.json()) const url = 'https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result';
const data = {
request_id: 'a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8'
};
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 -X POST "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result" \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
--data-raw '{
"request_id": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"
}' 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 PollingExample {
public static void main(String[] args) throws Exception {
String url = "https://gateway.pixazo.ai/flux-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result";
String json = "{\n" +
" \"request_id\": \"a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8\"\n" +
"}";
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
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-2-pro-text-to-image-trainer-712/v1/flux-2-pro-text-to-image-trainer-request-result';
$data = [
'request_id' => 'a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8'
];
$json = 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);
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.2 Trainer API Pricing
| Resolution | Price (USD) |
|---|---|
| All Resolution | $8 |
Ready to generate FLUX.2 Trainer API assets?
Start with an API key, then automate your pipeline.
