BEFOREAI / DEVELOPER DOCUMENTATIONGood experiences start with good foundations.
Start here / Quickstart

Your first request.

Go from credentials to a virtual try-on request, with a simple server-side integration outline.

Before you start

You will need an API key, the gateway URL supplied during onboarding, and HTTPS URLs for a person photo and a garment image. The gateway must be able to fetch both images without cookies or custom headers.

No credentials yet? Request API access. This website does not issue keys automatically.

1. Set your server environment

Server environment
export BEFOREAI_GATEWAY_URL="https://YOUR_ASSIGNED_GATEWAY"
export BEFOREAI_API_KEY="YOUR_API_KEY"
export PERSON_IMAGE_URL="https://your-cdn.example.com/person.jpg"
export GARMENT_IMAGE_URL="https://your-cdn.example.com/shirt.jpg"

Replace the placeholders with your assigned gateway, credentials, and actual image URLs. Do not use NEXT_PUBLIC_ variables for API credentials.

2. Submit a try-on

cURL request
curl -X POST "$BEFOREAI_GATEWAY_URL/v1/tryon" \
  -H "X-API-Key: $BEFOREAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    "person_image_url": "$PERSON_IMAGE_URL",
    "garment_image_urls": "$GARMENT_IMAGE_URL"
  }"
One BeforeAI integration.

Your requests describe the experience. BeforeAI manages processing behind the API. Confirm credit costs and available capabilities during onboarding.

3. Handle the result

A successful immediate result includes generation_id and result_urls. Display a returned image URL in your interface. Credit fields report the charge and remaining balance.

A queued request returns HTTP 202 with a generation ID and status: "queued". Poll the job with the same API key until it completes or fails.

Check a queued job
curl "$BEFOREAI_GATEWAY_URL/v1/tryon/GENERATION_ID" \
  -H "X-API-Key: $BEFOREAI_API_KEY"

Replace GENERATION_ID with the ID returned by the submission. See queued generation handling before building your production flow.

Choose your next step

Read the Try-On guide for fields and job states, or the Stylist guide to build a preference-to-outfit journey.