Quickstart
Run your first GenFashion virtual try-on through the API, from getting a key to fetching the result image.
By the end of this page you will have sent a shopper photo and a garment to the API, and fetched the finished try-on image.
You need a GenFashion account. New accounts start with free credits, enough for your first try-ons. If you would rather not write code, try the whole flow in the Playground.
1. Get a secret key#
Sign in to GenFashion, open Settings > API keys, and copy a secret key. It starts with sb_secret_. Keep it on your server and never put it in a web page.
2. Add a product to your catalogue#
A try-on needs a product that already exists in your catalogue, so add one in the console or through a store sync. Give it an external ID, such as shirt-42. A garment the API has not seen is refused with PRODUCT_NOT_FOUND.
3. Start the try-on#
Send the shopper photo as a url or as a base64 dataUrl, not both, and name the product by its external ID:
curl -X POST "https://genfashion.buildframe.tech/api/tryon/v1/try-on" \
-H "x-api-key: sb_secret_your_key" \
-H "Content-Type: application/json" \
-d '{
"person": { "url": "https://shop.example.com/shopper.jpg" },
"products": [{ "externalId": "shirt-42" }]
}'The response is 202 Accepted, which means the photo passed screening and the try-on has started:
{ "generationId": "gen_3f9a1c2b7d4e8a10", "status": "PROCESSING", "pollAfterMs": 5000 }A 4xx response means the request was refused. No credit is used, and there is nothing to poll for.
4. Fetch the result#
Ask for the generation every 5 seconds, using the generationId from the last step:
curl "https://genfashion.buildframe.tech/api/tryon/v1/generations/gen_3f9a1c2b7d4e8a10" \
-H "x-api-key: sb_secret_your_key"Keep asking until status is COMPLETED or FAILED. A try-on usually takes 45 to 60 seconds. When it completes, the response has a resultImageUrl, which is a signed link valid for 15 minutes. Download the image if you need it for longer.
Next steps#
- See every field, limit and error code in the Try-On API reference.
- Selling on Shopify? See Connect a Shopify store.
- Selling from your own store? Add the storefront widget.
- In production, use webhooks instead of asking repeatedly.