FASHN Virtual Try-On V1.6 API Documentation

Fashn Virtual Try-On generate request - Request Code

POST https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request Content-Type: application/json Cache-Control: no-cache Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY { "model_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg", "garment_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg", "category": "auto", "mode": "balanced", "garment_photo_type": "auto", "moderation_level": "permissive", "num_samples": 1, "segmentation_free": true, "output_format": "png" }
import requests url = "https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache", "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY" } data = { "model_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg", "garment_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg", "category": "auto", "mode": "balanced", "garment_photo_type": "auto", "moderation_level": "permissive", "num_samples": 1, "segmentation_free": True, "output_format": "png" } response = requests.post(url, json=data, headers=headers) print(response.json())
const url = 'https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY' }; const data = { model_image: 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg', garment_image: 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg', category: 'auto', mode: 'balanced', garment_photo_type: 'auto', moderation_level: 'permissive', num_samples: 1, segmentation_free: true, output_format: 'png' }; 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 -X POST "https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \ --data-raw '{ "model_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg", "garment_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg", "category": "auto", "mode": "balanced", "garment_photo_type": "auto", "moderation_level": "permissive", "num_samples": 1, "segmentation_free": true, "output_format": "png" }'
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 json = """ { "model_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg", "garment_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg", "category": "auto", "mode": "balanced", "garment_photo_type": "auto", "moderation_level": "permissive", "num_samples": 1, "segmentation_free": true, "output_format": "png" } """; HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request")) .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 $url = 'https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request'; $data = json_encode([ 'model_image' => 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg', 'garment_image' => 'https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg', 'category' => 'auto', 'mode' => 'balanced', 'garment_photo_type' => 'auto', 'moderation_level' => 'permissive', 'num_samples' => 1, 'segmentation_free' => true, 'output_format' => 'png' ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); 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' ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?>

Output

Successful API response:

{ "status": "IN_QUEUE", "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" }

Request Body - Fashn Virtual Try-On generate request

Parameters for https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request:

ParameterRequiredTypeDescription
model_imageYesstringURL to a human model image (full body or upper body). Must be accessible via public HTTP/HTTPS endpoint.
garment_imageYesstringURL to a garment image (on-model or flat-lay). Must be a public HTTP/HTTPS endpoint.
categoryNostringSpecifies garment category to improve segmentation. Values: auto, top, bottom, dress, outerwear.
modeNostringProcessing mode balancing speed and quality. Values: fast, balanced, high_quality.
garment_photo_typeNostringSpecifies the type of garment image provided. Values: auto, on_model, flat_lay.
moderation_levelNostringContent moderation sensitivity. Values: strict, moderate, permissive.
num_samplesNointegerNumber of try-on variations to generate. Maximum value: 5.
segmentation_freeNobooleanWhen true, bypasses detailed segmentation for faster processing (may reduce accuracy on complex garments).
output_formatNostringOutput image format. Values: png, jpeg.

Example Request - Fashn Virtual Try-On generate request

JSON
{ "model_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_human.jpg", "garment_image": "https://pub-582b7213209642b9b995c96c95a30381.r2.dev/vt_top.jpeg", "category": "auto", "mode": "balanced", "garment_photo_type": "auto", "moderation_level": "permissive", "num_samples": 1, "segmentation_free": true, "output_format": "png" }

Response - Fashn Virtual Try-On generate request

JSON
{ "status": "IN_QUEUE", "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" }

Retrieving Results

After submitting your request, use this endpoint to check status and retrieve results.

Endpoint

POST https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result

Request Body

{ "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" }

Request Code

POST https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result Content-Type: application/json Cache-Control: no-cache Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY { "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" }
import requests url = "https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result" headers = { "Content-Type": "application/json", "Cache-Control": "no-cache", "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY" } data = { "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" } response = requests.post(url, json=data, headers=headers) print(response.json())
const url = 'https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result'; const headers = { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', 'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY' }; const data = { request_id: 'fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c' }; 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 -X POST "https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result" \ -H "Content-Type: application/json" \ -H "Cache-Control: no-cache" \ -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \ --data-raw '{ "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" }'
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 json = """ { "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c" } """; HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result")) .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 $url = 'https://gateway.pixazo.ai/fashn-virtual-try-on-917/v1/fashn-virtual-try-on-request-result'; $data = json_encode([ 'request_id' => 'fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c' ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); 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' ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?>

Response States

StatusDescription
IN_QUEUERequest is queued and awaiting processing.
IN_PROGRESSThe try-on generation is actively running.
COMPLETEDThe request completed successfully. Results are available in the images array.
FAILEDThe request failed due to invalid inputs, service error, or moderation rejection. Check error_message for details.

Example Success Response

{ "status": "COMPLETED", "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c", "images": [ { "url": "https://storage.pixazo.ai/results/fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c/output_0.png", "width": 576, "height": 864, "content_type": "image/png" } ], "metadata": { "mode": "balanced", "num_samples": 1, "output_format": "png", "processing_time_seconds": 14.2 } }

Example In-Progress Response

{ "status": "IN_PROGRESS", "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c", "queue_position": 2, "estimated_time_remaining_seconds": 8 }

Example Failed Response

{ "status": "FAILED", "request_id": "fashn-req-8a2d1e35-7b1f-4b19-9e3a-3d7e2a6b0a1c", "error_code": "INVALID_IMAGE_URI", "error_message": "The provided garment_image URL is not accessible or returns a 404 status." }

Request Headers

HeaderDescription
Content-TypeMust be set to application/json
Cache-ControlMust be set to no-cache
Ocp-Apim-Subscription-KeyYour API subscription key for authentication

Response Handling

The Fashn Virtual Try-On 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 CodeDescriptionResponse Body
200Success - The request was successfully processed.{ "success": true, ... }
Bad Request - The request contains invalid parameters or missing fields.{ "error": "Invalid request parameters" }
401Unauthorized - The provided subscription key is missing or invalid.{ "error": "Invalid or missing authentication" }
403Forbidden - The subscription does not have access to this API or action.{ "error": "Access denied for this operation" }
404Not Found - The requested resource or endpoint could not be found.{ "error": "Endpoint not found" }
Too Many Requests - The request rate limit has been exceeded.{ "error": "Rate limit exceeded, please retry later" }
500Internal Server Error - An unexpected error occurred on the server.{ "error": "An unexpected error occurred, please try again later" }

Example Error Response

{ "error": "Invalid parameters" }

FASHN Virtual Try-On V1.6 API Pricing

Resolution Price (USD)
All Resolution$0.075