TryItOn
API Reference

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 urls
curl -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.

ParameterTypeDefaultDescription
model_imagestring—Required. The person, as a public http(s) URL or a base64 data URL (data:image/<type>;base64,...).
garment_imagestring—Required. The item, as a URL or base64 data URL. A product photo on a plain background or a flat lay works best.
categorystringautoWhat the item is: auto, clothing, eyewear, footwear, headwear, jewelry, accessories or others. auto detects it. See Categories and subcategories.
subcategorystring—Where the item goes. Required for clothing, jewelry and accessories. Leave it out for every other category, including auto.
num_samplesinteger1Number of output images, 1–4. Each image costs 1 credit.
output_formatstringpngpng or jpeg.
moderation_levelstringpermissiveDeprecated. 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.
modestring—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.

categoryValid subcategory valuessubcategory
auto—omit (detected for you)
clothingauto, tops, bottoms, dressesrequired
eyewear—omit
footwear—omit
headwear—omit
jewelryrings, earrings, necklaces, bracelets, ankletsrequired
accessorieswatches, belts, scarves, bags, gloves, tiesrequired
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.

Statuserror.nameWhen
400ImageLoadErrormodel_image or garment_image is missing.
400InvalidCategoryThe category / subcategory pair isn't in the table above.
400InvalidNumSamplesnum_samples isn't an integer from 1 to 4.
400InvalidOutputFormatoutput_format isn't png or jpeg.
400InvalidModerationLevelmoderation_level isn't conservative, permissive or none.
403ForbiddenThe Authorization header is missing or malformed, the API key is invalid, or the account is disabled.
413PayloadTooLargeThe JSON body is over 12 MB. Send large images as URLs.
429RateLimitExceededMore than 10 try-on submits in a minute on your account, or more than 300 requests a minute from your IP.
429OutOfCreditsYour spendable credits are fewer than num_samples.
429ConcurrencyLimitExceeded5 or more credits are already held by running jobs. Wait for one to finish.
500InternalServerErrorThe 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.

On this page