Clothing & Accessories Try-On API
Virtual try-on API for clothing, eyewear, footwear, jewelry and accessories. Send a person photo and a product image, then poll for the result.
The fashion endpoint of the virtual try-on API puts a garment or accessory on a person. Send a photo of the person
(model_image) and an image of the item (garment_image). The API answers right away with a jobId, and you poll
Get Job Status until the result images are ready. One endpoint covers clothing,
eyewear, footwear, headwear, jewelry, accessories and other wearables.
POST
https://tryiton.now/api/v1/tryon/fashion
Each output image costs 1 credit, charged only for images produced. See Virtual Try-On API Pricing & Credits.
Request
Each SDK example submits the try-on and waits for the result. See SDKs to install one.
import { TryItOn } from "tryiton";
const client = new TryItOn({ apiKey: process.env.TRYITON_API_KEY });
const jobId = await client.tryOnFashion({
modelImage: "https://example.com/model.jpg",
garmentImage: "https://example.com/garment.jpg",
category: "clothing",
subcategory: "tops",
});
// Clothing jobs can outlast the 120 s default wait under load.
const urls = await client.waitForResult(jobId, { timeoutMs: 360_000 });
console.log(urls);import os
from tryiton import TryItOn
client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])
job_id = client.try_on_fashion(
model_image="https://example.com/model.jpg",
garment_image="https://example.com/garment.jpg",
category="clothing",
subcategory="tops",
)
# Clothing jobs can outlast the 120 s default wait under load.
urls = client.wait_for_result(job_id, timeout=360)
print(urls)package main
import (
"context"
"fmt"
"log"
"os"
"time"
tryiton "github.com/tryiton-now/tryiton-go/v2"
)
func main() {
client, err := tryiton.New(os.Getenv("TRYITON_API_KEY"))
if err != nil {
log.Fatal(err)
}
// WaitForResult has no timeout of its own: the context sets it.
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Minute)
defer cancel()
jobID, err := client.TryOnFashion(ctx, tryiton.FashionParams{
ModelImage: "https://example.com/model.jpg",
GarmentImage: "https://example.com/garment.jpg",
Category: "clothing",
Subcategory: "tops",
})
if err != nil {
log.Fatal(err)
}
urls, err := client.WaitForResult(ctx, jobID, 2*time.Second)
if err != nil {
log.Fatal(err)
}
fmt.Println(urls)
}<?php
require 'vendor/autoload.php';
use TryItOn\Client;
$client = new Client(getenv('TRYITON_API_KEY'));
$jobId = $client->tryOnFashion([
'model_image' => 'https://example.com/model.jpg',
'garment_image' => 'https://example.com/garment.jpg',
'category' => 'clothing',
'subcategory' => 'tops',
]);
// Poll every 2 s for up to 360 s (longer than the 5-minute job timeout).
$urls = $client->waitForResult($jobId, 2.0, 360.0);
print_r($urls);require "tryiton"
client = Tryiton::Client.new(api_key: ENV.fetch("TRYITON_API_KEY"))
job_id = client.try_on_fashion(
model_image: "https://example.com/model.jpg",
garment_image: "https://example.com/garment.jpg",
category: "clothing",
subcategory: "tops"
)
# Clothing jobs can outlast the 120 s default wait under load.
urls = client.wait_for_result(job_id, timeout: 360)
puts urlscurl -X POST https://tryiton.now/api/v1/tryon/fashion \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_image": "https://example.com/model.jpg",
"garment_image": "https://example.com/garment.jpg",
"category": "clothing",
"subcategory": "tops"
}'Then poll GET https://tryiton.now/api/v1/status/{jobId} about every 2 seconds. See
Get Job Status.
Parameters
Send a JSON body with Content-Type: application/json.
| Parameter | Type | Default | Description |
|---|---|---|---|
model_image | string | — | Required. The person, as a public http(s) URL or a base64 data URL (data:image/<type>;base64,...). |
garment_image | string | — | Required. The item, as a URL or base64 data URL. A product photo on a plain background or a flat lay works best. |
category | string | auto | What the item is: auto, clothing, eyewear, footwear, headwear, jewelry, accessories or others. auto detects it. See Categories and subcategories. |
subcategory | string | — | Where the item goes. Required for clothing, jewelry and accessories. Leave it out for every other category, including auto. |
num_samples | integer | 1 | Number of output images, 1–4. Each image costs 1 credit. |
output_format | string | png | png or jpeg. |
moderation_level | string | permissive | Deprecated. Must be conservative, permissive or none if sent, but it has no effect: the AI providers' own safety filters always apply. Leave it out; it will be removed in a future version. |
mode | string | — | Deprecated. Accepted for backward compatibility and ignored. Leave it out; it will be removed in a future version. |
Categories and subcategories
category tells the API what the item is, and subcategory tells it where the item sits on the body.
category | Valid subcategory values | subcategory |
|---|---|---|
auto | — | omit (detected for you) |
clothing | auto, tops, bottoms, dresses | required |
eyewear | — | omit |
footwear | — | omit |
headwear | — | omit |
jewelry | rings, earrings, necklaces, bracelets, anklets | required |
accessories | watches, belts, scarves, bags, gloves, ties | required |
others | — | omit |
Any other combination returns 400 InvalidCategory. That includes a subcategory sent with auto or with a
category that takes none, a missing subcategory for clothing, jewelry or accessories, and a value from another
category's list.
Valid selections look like this:
{ "category": "clothing", "subcategory": "tops" }{ "category": "jewelry", "subcategory": "necklaces" }{ "category": "eyewear" }Auto-detection
With category set to auto or left out, the API fetches garment_image and classifies it before it queues the job.
The submit call takes a little longer as a result. If detection fails, the item is treated as clothing
(clothing / auto). Pass an explicit category when you already know the item type. It's faster and it avoids a wrong
guess.
Response
A successful submit returns 201 with the job id. Pass it to
GET /status/{id} to get the result.
201 Created
{
"ok": true,
"jobId": "64b7f1a9d9a3b8e5c7f9a123"
}When the job completes, output holds up to num_samples image URLs. If some images fail to generate, output can hold
fewer, and you're charged only for the images it contains. A job that fails completely costs nothing.
Errors
Errors use the standard envelope { "ok": false, "error": { "name": "...", "message": "..." } }. Branch on
error.name. See Error Codes & Handling.
| Status | error.name | When |
|---|---|---|
| 400 | ImageLoadError | model_image or garment_image is missing. |
| 400 | InvalidCategory | The category / subcategory pair isn't in the table above. |
| 400 | InvalidNumSamples | num_samples isn't an integer from 1 to 4. |
| 400 | InvalidOutputFormat | output_format isn't png or jpeg. |
| 400 | InvalidModerationLevel | moderation_level isn't conservative, permissive or none. |
| 403 | Forbidden | The Authorization header is missing or malformed, the API key is invalid, or the account is disabled. |
| 413 | PayloadTooLarge | The JSON body is over 12 MB. Send large images as URLs. |
| 429 | RateLimitExceeded | More than 10 try-on submits in a minute on your account, or more than 300 requests a minute from your IP. |
| 429 | OutOfCredits | Your spendable credits are fewer than num_samples. |
| 429 | ConcurrencyLimitExceeded | 5 or more credits are already held by running jobs. Wait for one to finish. |
| 500 | InternalServerError | The job couldn't be queued. Nothing was charged, so retrying is safe. |
An image URL that can't be fetched doesn't fail the submit. The job fails later, and
GET /status/{id} returns status: "failed" with the reason.
Notes
- Images. URLs are fetched server-side and must stay reachable while the job runs. See Image Guidelines for Best Try-On Results for input limits and photo tips.
- Waiting. There are no webhooks. Poll
GET /status/{id}about every 2 seconds, which is what the SDK wait functions do. Jobs still processing after 5 minutes fail with"Timed out."and aren't charged. See Jobs, Polling & Retries. - Rate limits. The 10-per-minute try-on limit is shared by the fashion, hairstyle and tattoo endpoints and by try-ons made in the TryItOn app and storefront widget on the same account. See Rate Limits & Concurrency.
- Results. Result images are deleted about 72 hours after you submit the job. Download the ones you want to keep.
Data Retention & Privacy
What the TryItOn virtual try-on API stores and for how long: job records, input images, 72-hour result deletion, live garments and live video streams.
Hairstyle
Hairstyle try-on API: preview any of 34 haircuts and a free-text hair color on a face photo. Parameters, SDK examples, response and error codes.