TryItOn Python SDK — AI Virtual Try-On API
Official Python client for the TryItOn virtual try-on API. Add photoreal AI virtual try-on for clothing, accessories, hairstyles, and tattoos to your Python application with a few lines of code.
- Virtual clothing try-on and accessory try-on (eyewear, footwear, headwear, jewelry)
- Hairstyle and tattoo try-on
- Type-hinted client with a built-in job polling helper
Full API reference: docs.tryiton.now · Get an API key: tryiton.now/app/developer
Installation
pip install tryiton
Requires Python 3.8 or later.
Quickstart: run a virtual try-on
Submit a garment and a model photo, then wait for the generated result image.
import os
from tryiton import TryItOn
client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])
# Submit a clothing try-on
job_id = client.try_on_fashion(
model_image="https://example.com/model.jpg",
garment_image="https://example.com/tshirt.jpg",
category="clothing",
subcategory="tops",
)
# Poll until the job completes and return the output image URL(s)
urls = client.wait_for_result(job_id)
print(urls[0]) # CDN URL, available for 72 hours
Image inputs accept a public URL or a base64 data URL (data:image/png;base64,...).
Core parameters
try_on_fashion covers clothing and accessory try-on. The most important parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
model_image |
str | Yes | URL or base64 data URL of the person. |
garment_image |
str | Yes | URL or base64 data URL of the garment or accessory. |
category |
str | No | Item type: auto, clothing, eyewear, footwear, headwear, jewelry, accessories, or others. auto detects it for you. |
subcategory |
str | No | Required for clothing (tops, bottoms, dresses), jewelry, and accessories. |
Additional options (mode and moderation_level for clothing; num_samples 1–4 and output_format png/jpeg for every try-on, including hairstyle and tattoo) are documented in the API reference.
Other endpoints
# Hairstyle try-on (see tryiton.HAIRCUTS for all supported values)
client.try_on_hairstyle(face_image=face_url, haircut="BuzzCut", hair_color="ash blonde")
# Tattoo try-on — place it with free text...
client.try_on_tattoo(body_image=body_url, design_image=design_url, placement="on the right forearm, small")
# ...or pin the exact spot with a region box (normalized 0-1, from the image's top-left)
client.try_on_tattoo(body_image=body_url, design_image=design_url, region={"x": 0.32, "y": 0.18, "w": 0.28, "h": 0.34})
# Poll a job manually, or check your credit balance
status = client.get_status(job_id) # Status(status, output, error)
credits = client.get_credits() # Credits(on_demand, subscription, purchased, reserved)
Live try-on (real-time webcam)
Your server prepares garments and starts sessions with the API key. The shopper's browser streams with the
tryiton-live npm package, using only the session-scoped response.
# Once per product, e.g. at catalog sync (cached per image + category):
garment = client.prepare_live_garment(product_image_url, category="clothing", subcategory="tops")
# When a shopper opens live try-on. Return `start` to the browser as-is (e.g. as JSON):
start = client.start_live_session(
garment_id=garment["id"],
end_user_id=shopper_id, # one stream per end user
allowed_origin="https://shop.example.com", # locks the media token to your site
)
client.get_live_session(start["session"]["id"]) # {"status", "seconds", "creditsCharged", ...}
client.stop_live_session(start["session"]["id"]) # end it from your server
client.get_live_config() # {"enabled", "secondsPerCredit", "maxSeconds", ...}
Billing is per secondsPerCredit seconds of streamed video, from the first try-on frame. Garment switches during a
session are free.
prepare_live_garment also takes optional overrides:
client.prepare_live_garment(
product_image_url,
category="footwear",
detail_images=[side_view_url, back_view_url], # up to 3 extra views; they only sharpen the description
description="black leather knee-high boots", # your description (max 200), used in the generated prompt
instructions="Replace only the shoes with the boots.", # or your own prompt (max 1000), used verbatim
enhance_prompt=False, # keep the prompt as-is (default True)
)
Outfits
Combine 2-3 prepared garments into one outfit worn together. The outfit's id works wherever a garment id does
(start_live_session, the browser's switchGarment). To swap one item, prepare the new combination (cached) and
switch to it.
top = client.prepare_live_garment(shirt_url, category="clothing", subcategory="tops")
trousers = client.prepare_live_garment(trousers_url, category="clothing", subcategory="bottoms")
shoes = client.prepare_live_garment(shoes_url, category="footwear")
outfit = client.prepare_live_outfit([top["id"], trousers["id"], shoes["id"]])
# outfit["category"] == "outfit", outfit["items"] = the garment ids top to bottom
start = client.start_live_session(garment_id=outfit["id"], end_user_id=shopper_id)
# Later the shopper picks another top: prepare that outfit and switch the running stream to it.
jacket = client.prepare_live_garment(jacket_url, category="clothing", subcategory="tops")
next_outfit = client.prepare_live_outfit([jacket["id"], trousers["id"], shoes["id"]])
# Send next_outfit["id"] to the browser, which calls live.switchGarment(id) (tryiton-live).
prepare_live_outfit also takes instructions and enhance_prompt, as above.
Error handling
All failures raise TryItOnError, which carries the HTTP status code and the API error name.
from tryiton import TryItOn, TryItOnError
try:
client.try_on_fashion(...)
except TryItOnError as err:
print(err.status, err.error_name, str(err)) # e.g. 429, "OutOfCredits"
Typing
The package ships py.typed. get_status and get_credits return the Status and Credits dataclasses. The live
methods return plain dicts typed as TypedDicts (LiveConfig, LiveGarment, LiveSession, LiveSessionStart),
all importable from tryiton.
Notes
- Output image URLs expire 72 hours after completion. Download any results you want to keep.
- Failed jobs are never charged.
Development
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest # unit tests + the shared contract cases
python -m mypy tryiton # strict type check
tests/fixtures/sdk-cases.json holds the request/response cases every TryItOn SDK runs. It is generated: edit the
source in the backend repo (api-contract/sdk-cases.json) and re-sync, never the copy here. Changes are listed in
CHANGELOG.md.
Documentation
Full documentation, parameter reference, and guides: docs.tryiton.now
License
MIT
Metadata
Release files for tryiton 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tryiton-2.2.0.tar.gz | 16.6 kB | Without provenance | Details for tryiton-2.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tryiton-2.2.0-py3-none-any.whl | Python 3 | none | any | Details for tryiton-2.2.0-py3-none-any.whl |
Total release size: 28.3 kB
Release files / tryiton-2.2.0.tar.gz
| Download URL | tryiton-2.2.0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a01cdcde7a503c43485e866fec1073bd1015ed08eb44b62a4897a61b6c91aafe
|
|
BLAKE2b-256 checksum How to use checksums |
7795feb1db035bb818bb11e338908ea42b8d8b61facf724c47ce5ab89fb6f1f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / tryiton-2.2.0-py3-none-any.whl
| Download URL | tryiton-2.2.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49f9de9e61cd60b1b46e279f69133a39d1e42e022b6647dc7869354844c7fbb7
|
|
BLAKE2b-256 checksum How to use checksums |
1d9782a1bda321c3137d11e765bd7c9a03ada17d8caa1f19f69abd4c0b1a2173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for tryiton 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.