TryItOn
Concepts

Rate Limits & Concurrency

Rate limits and concurrency for the virtual try-on API: requests per minute per IP and per account, how credit holds cap parallel jobs, and how to back off.

The virtual try-on API applies two kinds of limits. Rate limits cap how many requests you send per time window. Concurrency caps how much work can run at once, measured in held credits. Both return 429 with a different error.name, and you handle them differently.

Rate limits

ScopeEndpointsLimitCounted per
All requestsEvery /api/v1 endpoint, including /health300 requests / minuteIP address
Photo try-onsPOST /tryon/fashion, /tryon/hairstyle and /tryon/tattoo combined10 requests / minuteAccount
Live garmentsPOST /live/garments120 requests / minuteAccount
Live sessionsPOST /live/sessions300 requests / hourAccount
Live heartbeatPOST /live/sessions/{id}/heartbeat (browser)90 requests / minuteIP address
Live garment switchPOST /live/sessions/{id}/garments/{garmentId} (browser)30 requests / minuteIP address
Live endPOST /live/sessions/{id}/end (browser)120 requests / minuteIP address

Things to know:

  • The photo try-on limit is per account, not per key. Creating more keys doesn't raise it. Try-ons made on the same account in the TryItOn app and the storefront widget count toward the same 10 per minute.
  • The 300/minute IP limit is shared by every request from that IP, polling included. Several workers behind one NAT address share one budget.
  • Over a limit you get 429 with error.name: "RateLimitExceeded". The API doesn't send a Retry-After header or rate-limit headers.

Concurrency

Every running job and live session holds credits until it ends: a photo try-on holds num_samples credits, a live session holds 1. While 5 or more credits are held on your account, new photo try-ons and new live sessions are refused with 429 ConcurrencyLimitExceeded.

The check looks at what's already held, not at the size of the new request. A worked example on an account with plenty of credits:

StepRequestHeld beforeResultHeld after
1Fashion try-on, num_samples: 40Accepted4
2Hairstyle try-on, num_samples: 14Accepted (4 is under 5)5
3Tattoo try-on, num_samples: 15429 ConcurrencyLimitExceeded5
4Step 1's job completes—Its 4 credits are charged or released1
5Retry step 31Accepted2

So with num_samples: 1 you can run up to 5 jobs at once. With num_samples: 4 you can run 2 (the second one is accepted because 4 is under 5, which brings the total to 8 held).

Two more rules:

  • Live sessions: at most 3 can run at once per account. A fourth start returns 429 LiveTryonBusy. Each running session also holds 1 credit toward the limit above.
  • Credits come first: if you're also short of credits, you get 429 OutOfCredits instead of ConcurrencyLimitExceeded.

Jobs usually finish well within a minute. A job still running after 5 minutes is failed and its hold is released, so a stuck job can't block you for long.

How to back off

  • RateLimitExceeded: retry with exponential backoff and jitter, capped at 60 seconds, the length of the window. Better, pace yourself: keep photo try-on submits under 10 per minute per account with a queue on your side.
  • ConcurrencyLimitExceeded: don't retry on a timer. Wait until one of your running jobs reaches completed or failed, then submit the next. A local queue that keeps at most 5 one-image jobs (or 2 four-image jobs) in flight avoids the error entirely.
  • OutOfCredits: retrying won't help. Buy credits at tryiton.now/app/billing.
  • Polling: poll each job every 2 seconds or slower. With many jobs in flight, the 300/minute IP limit is the one you hit first.

A retry helper for submits:

import { TryItOn, TryItOnError } from "tryiton";

const client = new TryItOn({ apiKey: process.env.TRYITON_API_KEY });
const RETRYABLE = new Set(["RateLimitExceeded", "ConcurrencyLimitExceeded"]);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function submitWithBackoff(submit, maxAttempts = 6) {
  for (let attempt = 1; ; attempt++) {
    try {
      return await submit();
    } catch (err) {
      const retryable = err instanceof TryItOnError && RETRYABLE.has(err.errorName);
      if (!retryable || attempt === maxAttempts) throw err;
      const delayMs = Math.min(60_000, 2_000 * 2 ** (attempt - 1)) + Math.random() * 1_000;
      await sleep(delayMs);
    }
  }
}

const jobId = await submitWithBackoff(() =>
  client.tryOnFashion({
    modelImage: "https://example.com/model.jpg",
    garmentImage: "https://example.com/shirt.jpg",
  }),
);
console.log(jobId);
import os
import random
import time

from tryiton import TryItOn, TryItOnError

client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])
RETRYABLE = {"RateLimitExceeded", "ConcurrencyLimitExceeded"}


def submit_with_backoff(submit, max_attempts=6):
    for attempt in range(1, max_attempts + 1):
        try:
            return submit()
        except TryItOnError as err:
            if err.error_name not in RETRYABLE or attempt == max_attempts:
                raise
            delay = min(60.0, 2.0 * 2 ** (attempt - 1)) + random.random()
            time.sleep(delay)


job_id = submit_with_backoff(
    lambda: client.try_on_fashion(
        model_image="https://example.com/model.jpg",
        garment_image="https://example.com/shirt.jpg",
    )
)
print(job_id)

If your production traffic needs higher limits, contact contact@tryiton.now.

On this page