JSPM

@genlook/api

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q76147F
  • License MIT

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.

Package Exports

  • @genlook/api

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/api

3. 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. Reference an existing product, or upsert one inline.
// The engine automatically detects the best model based on the product image/title/description.
const generation = await client.tryOn.create({
  product: {
    externalId: "dog-sweater-01",
    title: "Cozy Knit Pet Sweater",
    description: "Warm red knit sweater for small to medium dogs",
    images: [{ url: "https://cdn.example.com/pet-sweater.jpg" }],
  },
  customer: { id: imageId },
});

// 3. Wait for the result
const result = await client.generations.waitFor(generation.generationId);
console.log("Try-on Result URL:", result.resultImageUrl);

API Resources

Resource Methods Purpose
client.images upload Pre-upload customer photos and reuse the imageId across generations.
client.tryOn create Queue a try-on generation (inline-upsert product or reference by ID).
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({
    product: { externalId: "shirt-42" },
    customer: { 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) {
    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, // 429 / 5xx / network retries
  fetch: customFetch, // inject your own fetch
});

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