@genlook/api
v0.6.0
Published
Official TypeScript SDK for the Genlook API. A powerful virtual try-on API for clothing, accessories, and petwear. Add photorealistic AI virtual try-on to any app or store.
Maintainers
Readme
@genlook/api
Official TypeScript SDK for the Genlook Virtual Try-On API.
What is Genlook?
Genlook is a powerful API for virtual try-on that works on any product type—from clothing and accessories to petwear. Add photorealistic AI virtual try-on to any e-commerce store, mobile app, or internal tool. We turn a product image and a person's photo into a highly realistic virtual fitting room experience, eliminating the need for expensive photoshoots and models.
Whether you are building a clothing try-on feature, an AI fitting room, or a petwear virtual try-on experience, the @genlook/api package provides a strongly typed, zero-dependency (beyond Zod) SDK for Node 20+, Deno, Bun, and edge runtimes.
Use Cases
What you can build with the Genlook Virtual Try-On API:
- Virtual try-on for e-commerce — Let shoppers see themselves in your clothing before they buy, driving higher conversion and fewer returns.
- AI virtual fitting rooms — Create interactive, photorealistic try-on experiences on your product pages.
- Photoshoot replacement — Generate on-model product imagery without a studio.
- Personalized marketing — Power campaigns where each customer sees themselves wearing your apparel.
Supported Product Types
Genlook supports a wide variety of product categories. The API automatically classifies and routes the try-on generation based on the product.
Supported product types include:
- Clothes (Tops, bottoms, dresses, outerwear, suits, etc.)
- Lingerie (Bras, underwear, intimates, corsets, bodysuits)
- Glasses (Sunglasses, prescription eyewear)
- Shoes (Sneakers, boots, sandals)
- Hats (Caps, beanies, fedoras, headwear)
- Jewelry (Rings, necklaces, earrings, bracelets, pendants)
- Petwear (Dog/cat sweaters, costumes, bandanas, collars)
- Wigs (Wigs, hair extensions, hairpieces)
- Swimwear (Bikinis, one-pieces, trunks, board shorts)
- Accessories (Scarves, belts, gloves, ties, socks, watches)
- Handbags (Purses, totes, clutches, backpacks, crossbody bags)
- Fabric Closeups (Sarees, dupattas, flat fabric swatches)
- Pasties (Nipple covers, breast petals)
Getting Started
1. Get an API Key
To get your API key, visit: https://genlook.app/try-on/api
2. Install the SDK
pnpm add @genlook/api
# or
npm install @genlook/api
yarn add @genlook/api
bun add @genlook/api3. Quick Start
import { Genlook } from "@genlook/api";
import { readFile } from "node:fs/promises";
// Initialize the client
const client = new Genlook({ apiKey: process.env.GENLOOK_API_KEY! });
// 1. Upload the customer photo (reuse the imageId across many try-ons)
const { imageId } = await client.images.upload(await readFile("./customer.jpg"), {
mimeType: "image/jpeg",
});
// 2. Run the try-on and get the result in the same request.
// Reference an existing product by externalId, or describe it inline (created on first use).
const result = await client.tryOn.createSync({
products: [{
externalId: "dog-sweater-01",
title: "Cozy Knit Pet Sweater",
description: "Warm red knit sweater for small to medium dogs",
images: [{ source: { url: "https://cdn.example.com/pet-sweater.jpg" } }],
}],
person: { image: { source: { id: imageId } } },
});
// Usually COMPLETED. If it took longer than 90 s, wait for it.
const done =
result.status === "COMPLETED" ? result : await client.generations.waitFor(result.generationId);
console.log("Try-on Result URL:", done.resultImageUrl);Multi-product try-on
Pass 2 to 4 garments in products and they are worn together in one result (only those garments change, the rest of the outfit stays). Multi-product works with clothing only.
const outfit = await client.tryOn.createSync({
products: [
{ title: "White linen shirt", images: [{ source: { url: "https://cdn.example.com/shirt.jpg" } }] },
{ title: "Navy chino trousers", images: [{ source: { url: "https://cdn.example.com/chinos.jpg" } }] },
],
person: { image: { source: { id: imageId } } },
});
console.log(outfit.productExternalIds); // one id per product, in request order2K results
Set output.resolution to "2k" for a result of about 4 megapixels (2048 x 2048 px in area, the person photo's aspect ratio kept) instead of about 1 megapixel. It is the same try-on with real high-resolution detail on fabric, skin and hair. It costs 1 credit more than the same try-on in default resolution (a 2-product outfit in 2K is 3 credits) and takes a few seconds longer.
const hd = await client.tryOn.createSync({
products: [{ externalId: "shirt-42" }],
person: { image: { source: { id: imageId } } },
output: { resolution: "2k" },
});Prefer to queue the job and poll yourself? client.tryOn.create(...) returns a generationId right away; then call client.generations.waitFor(generationId).
API Resources
| Resource | Methods | Purpose |
| -------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------- |
| client.images | upload | Pre-upload customer photos and reuse the imageId across generations. |
| client.tryOn | createSync, create | Run a try-on: createSync returns the result, create queues it. |
| client.generations | retrieve, waitFor | Poll status; waitFor replaces hand-rolled polling loops. |
| client.products | upsert, list, iterate, get, delete, stats | Catalog management — optional. Most integrations use inline tryOn. |
| client.account | credits | Inspect remaining credit balance. |
| client.customers | delete | GDPR right-to-erasure (wipe per-customer images + anonymize generations). |
Error Handling
Every request that fails throws a typed GenlookError subclass. Branch on error.code or use instanceof:
import { Genlook, GenlookError, InsufficientCreditsError, ProductNotFoundError } from "@genlook/api";
try {
await client.tryOn.create({
products: [{ externalId: "shirt-42" }],
person: { image: { source: { id: imageId } } },
});
} catch (err) {
if (err instanceof ProductNotFoundError) {
// Cache miss — retry with the full inline payload.
} else if (err instanceof InsufficientCreditsError) {
// Surface "top up" CTA.
} else if (err instanceof GenlookError) {
// err.is("PRODUCT_NOT_FOUND") also works. Quote err.requestId to support.
console.error(err.code, err.message, err.requestId);
} else {
throw err;
}
}Configuration
const client = new Genlook({
apiKey: process.env.GENLOOK_API_KEY!,
baseUrl: "https://api.genlook.app/tryon/v1", // override for testing
timeoutMs: 60_000, // per-request budget
maxRetries: 2, // reads: 429/5xx/network. Try-ons and uploads: 429 only (never charged twice)
userAgent: "acme-shop/2.3", // appended to the SDK user agent
fetch: customFetch, // inject your own fetch
});
// Per-call options, on every method:
await client.tryOn.create(input, { signal: AbortSignal.timeout(10_000), maxRetries: 0 });Runtimes
- Node 20+ (preferred — picks up the global
fetch/FormData/Blob). - Deno ≥ 1.40.
- Bun ≥ 1.0.
- Cloudflare Workers / Vercel Edge — pass
{ fetch }if the runtime hides the global, otherwise it works automatically.
Browser is intentionally unsupported. API keys must not be embedded in client-side bundles — proxy requests through your backend.
License
MIT
