Skip to main content

Official Python SDK for the TryItOn virtual try-on API.

Project description

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_clothes(
    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_clothes 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
client.try_on_tattoo(body_image=body_url, design_image=design_url, placement="on the right forearm, small")

# 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)

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_clothes(...)
except TryItOnError as err:
    print(err.status, err.error_name, str(err))  # e.g. 429, "OutOfCredits"

Notes

  • Output image URLs expire 72 hours after completion. Download any results you want to keep.
  • Failed jobs are never charged.

Documentation

Full documentation, parameter reference, and guides: docs.tryiton.now

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tryiton-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tryiton-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file tryiton-1.0.0.tar.gz.

File metadata

  • Download URL: tryiton-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for tryiton-1.0.0.tar.gz
Algorithm Hash digest
SHA256 84b2ee2637afdf1926eb0b21eca09d982671d11087be261a528742d45082c293
MD5 ff648ab95937d13a3861b9b3131f8e27
BLAKE2b-256 1072d96a8b54baee9c8457f0aa466187e86ad6715a4636b7652dcde0794d0c51

See more details on using hashes here.

File details

Details for the file tryiton-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tryiton-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for tryiton-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a63ed487d7b2d5679f47e5df77915c88b49c26737167e12c112329486e1e40c
MD5 b5cf87d41bd7e4b0fd55fa82434c95f6
BLAKE2b-256 e25a775743ad96d4f504a442a5e2c980412286dfc69aa5e90a8b0cc280d958af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page