Official Node.js and TypeScript client for the TryItOn virtual try-on API. Add photoreal AI virtual try-on for clothing, accessories, hairstyles, and tattoos to your JavaScript or TypeScript application with a few lines of code.
- Virtual clothing try-on and accessory try-on (eyewear, footwear, headwear, jewelry)
- Hairstyle and tattoo try-on
- Fully typed, zero runtime dependencies (uses the native
fetchAPI) - Built-in job polling helper
Full API reference: docs.tryiton.now · Get an API key: tryiton.now/app/developer
npm install tryitonRequires Node.js 18 or later (or any runtime with a global fetch, such as Bun, Deno, or modern browsers). TypeScript types are bundled.
Submit a garment and a model photo, then wait for the generated result image.
import{TryItOn}from"tryiton";constclient=newTryItOn({apiKey: process.env.TRYITON_API_KEY});// Submit a clothing try-onconstjobId=awaitclient.tryOnFashion({modelImage: "https://example.com/model.jpg",garmentImage: "https://example.com/tshirt.jpg",category: "clothing",subcategory: "tops",});// Poll until the job completes and return the output image URL(s)const[resultUrl]=awaitclient.waitForResult(jobId);console.log(resultUrl);// CDN URL, available for 72 hoursImage inputs accept a public URL or a base64 data URL (data:image/png;base64,...).
tryOnFashion covers clothing and accessory try-on. The most important parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
modelImage | string | Yes | URL or base64 data URL of the person. |
garmentImage | string | Yes | URL or base64 data URL of the garment or accessory. |
category | string | No | Item type: auto, clothing, eyewear, footwear, headwear, jewelry, accessories, or others. auto detects it for you. |
subcategory | string | No | Required for clothing (tops, bottoms, dresses), jewelry, and accessories. |
Additional options (mode and moderationLevel for clothing; numSamples 1–4 and outputFormatpng/jpeg for every try-on, including hairstyle and tattoo) are documented in the API reference.
// Hairstyle try-on (see the HAIRCUTS export for all supported values)awaitclient.tryOnHairstyle({ faceImage,haircut: "BuzzCut",hairColor: "ash blonde"});// Tattoo try-on — place it with free text...awaitclient.tryOnTattoo({ bodyImage, designImage,placement: "on the right forearm, small"});// ...or pin the exact spot with a region box (normalized 0–1, from the image's top-left)awaitclient.tryOnTattoo({ bodyImage, designImage,region: {x: 0.32,y: 0.18,w: 0.28,h: 0.34}});// Poll a job manually, or check your credit balanceconststatus=awaitclient.getStatus(jobId);// { status, output, error }constcredits=awaitclient.getCredits();// { on_demand, subscription, purchased, reserved }All failures throw TryItOnError, which carries the HTTP status code and the API error name.
import{TryItOn,TryItOnError}from"tryiton";try{awaitclient.tryOnFashion({/* ... */});}catch(err){if(errinstanceofTryItOnError){console.error(err.status,err.errorName,err.message);// e.g. 429, "OutOfCredits"}}- Output image URLs expire 72 hours after completion. Download any results you want to keep.
- Failed jobs are never charged.
Full documentation, parameter reference, and guides: docs.tryiton.now
MIT