API Parameters Guide
Model Image
image URL | base64
model_image
is the primary image of the person on whom the virtual try-on will be performed. You can provide the image as a publicly accessible URL or a base64 string.
Use mode: performance
to quickly test and find model and garment combinations that work well. Once you're satisfied, switch to mode: quality
to produce a final high-quality result ready for publishing.
*Tips for selecting the best model image and avoiding common issues.
Garment Image
image URL | base64
garment_image
is the reference image of the clothing item to be tried on the model_image
. The image can be provided as a URL or a base64 string. FASHN supports a variety of garment photo types, as shown below:
*Infographic displaying supported garment image types ranked from best (left) to worst (right).
Read Image Preprocessing Best Practices to ensure your requests reach our servers fast and without issues
For Image URLs:
- Ensure the URL is publicly accessible without permission restrictions.
- Confirm the
Content-Type
header matches the image format (e.g.,image/jpeg
,image/png
).
For Base64 Images:
- Prefix the string with
data:image/<format>;base64,
where<format>
is the image type (e.g.,jpeg
,png
).
Category
'auto' | 'tops' | 'bottoms' | 'one-pieces'
Specifies the type of garment in the garment_image
to apply to the model_image
. If the garment image includes multiple items (e.g., a t-shirt and jeans), use this parameter to select which item to apply.
auto
(recommended): Automatically determines the garment category. For flat-lay or ghost mannequin images, garment type detection is automatic. For on-model images, full-body shots default to swapping the entire outfit, and focused shots (upper or lower body) select the most likely garment type (tops
orbottoms
).tops
: Specifies garments for the upper body (e.g., shirts, blouses).bottoms
: Specifies garments for the lower body (e.g., pants, skirts).one-pieces
: Specifies single-piece garments or full-body garments (e.g., dresses, jumpsuits).
*Examples of try-on results for categories 'tops'
, 'bottoms'
, and
'one-pieces'
.
Mode
performance | balanced | quality
The mode
parameter determines the trade-off between processing speed and output quality:
performance
: Fastest, with reduced image quality.balanced
: A middle ground, offering a good balance between speed and quality.quality
: Slowest, delivering the highest-quality results.
*Side-by-side comparison of results for 'performance'
, 'balanced'
, and
'quality'
modes.
Use mode: performance
to quickly test and find model and garment combinations that work well. Once you're satisfied, switch to mode: quality
to produce a final high-quality result ready for publishing.
Garment Photo Type
auto | model | flat-lay
Defines the garment photo type for optimal performance:
model
: Photos of garments on a model.flat-lay
: Flat-lay or ghost mannequin images.auto
: Automatically detects the photo type.
flat-lay
is required for precise handling of flat-lay images where elements like back neck labels or size tags should be excluded.
*Comparison of 'flat-lay'
and 'model'
configurations with flat-lay input.
Number of Samples
integer
The num_samples
parameter specifies how many images to generate in a single run. By increasing num_samples
, you can explore multiple variations simultaneously, improving the likelihood of achieving a desirable result.
Because num_samples
introduces diversity within a batch, its practical effect is similar to running multiple trials with different seeds. However, when used with the same seed
value, the results remain reproducible for a given num_samples
count.
Great try-on results might just be a seed change away! Conversely, a poor outcome doesn't necessarily mean the input combination won't work—sometimes a simple seed change can make all the difference. Use num_samples: 2-4
along with mode: performance
to quickly test multiple seeds and assess how sensitive your inputs are to seed variation.
Seed
integer
Default: 42
Min: 0
, Max: 2^32 - 1
The seed
parameter is used to set the random operations within the image generation process to a fixed state. This is crucial for reproducibility:
- Use the same seed value with the same inputs to consistently generate the exact same try-on result.
- Use a different seed value with the same inputs to force different variations of the try-on result. This is useful for exploring different aesthetic outcomes without changing your core
model_image
orgarment_image
.
Segmentation Free
boolean
Default: true
When set to true
, this parameter enables direct garment fitting without requiring explicit clothing segmentation from the input images. This is particularly useful for achieving a more natural look with bulkier garments, as it aims to preserve the model's body shape and skin texture more effectively. If you observe issues where the original garments are not properly removed in the try-on result, and it is critical for your use-case, set this to false
.
Moderation Level
'conservative' | 'permissive' | 'none'
Default: permissive
This parameter allows you to set the content moderation standards for the garment images processed by the API.
conservative
: Enforces stricter modesty standards, suitable for culturally sensitive contexts. It is designed to block images of underwear, swimwear, and revealing outfits.permissive
: This is the default setting. It allows images of swimwear, underwear, and revealing garments, but still blocks explicit nudity.none
: Disables all content moderation.
This technology is designed for ethical and appropriate virtual try-on applications. Misuse—such as generating inappropriate imagery of individuals without consent—violates our Terms of Service.
Setting moderation_level: none
does not absolve users from their responsibility to ensure ethical and lawful use. Violations may result in service denial.
Output Format
'png' | 'jpeg'
Default: png
This parameter specifies the desired format of the generated output image:
png
: Delivers the highest quality image, making it ideal for use cases where image fidelity is paramount, such as content creation, marketing materials, or high-resolution displays.jpeg
: Provides a faster response time with a slightly compressed image. This format is more suitable for real-time applications like consumer-facing virtual try-on experiences where speed is a priority over uncompressed quality.
Return Base64
boolean
Default: false
When set to true
, the API will return the generated image directly as a base64-encoded string in the response body, instead of providing a CDN (Content Delivery Network) URL. The base64 string will be appropriately prefixed according to the chosen output_format
(e.g., data:image/png;base64,...
or data:image/jpeg;base64,...
).
This option offers enhanced privacy, as it means user-generated outputs are not stored on Fashn.ai's servers when return_base64
is enabled, giving users more control over their data.