Try-On Python Quickstart
Run a virtual try-on in Python using the official tryiton SDK: submit a job, wait for completion, and read the output image URLs.
This quickstart uses the official tryiton
Python SDK to:
- Submit a try-on to the
/tryon/clothesendpoint. - Wait for the job to finish (the SDK polls
/status/<id>for you). - Read the output image URLs.
Install
pip install tryitonRequires Python 3.8 or later. See all libraries on the SDKs page.
Minimal example
This example uses URLs for the model and garment images. You can also pass a
base64 data URL (data:image/png;base64,...) for either image.
import os
from tryiton import TryItOn, TryItOnError
client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])
try:
# 1. Submit the try-on
job_id = client.try_on_clothes(
model_image="https://example.com/model.jpg",
garment_image="https://example.com/garment.jpg",
category="clothing",
subcategory="tops",
)
print("Job started:", job_id)
# 2. Wait for completion (polls status until done)
output = client.wait_for_result(job_id)
# 3. Read the result image URLs (valid for 72 hours)
print("Result:", output[0])
except TryItOnError as err:
print(f"Failed ({err.status} {err.error_name}): {err}")Prefer to poll yourself? Call client.get_status(job_id) in a loop instead of
wait_for_result.
Try-On JavaScript Quickstart
Run a virtual try-on in Node.js using the official tryiton SDK: submit a job, wait for completion, and read the output image URLs.
Try-On PHP Quickstart
Run a virtual try-on in PHP using the official tryiton/tryiton SDK: submit a job, wait for completion, and read the output image URLs.