# Quickstart

For AI agents: this is the Markdown version of https://docs.fashiolabs.com/quickstart.html. The index of all Fashio API docs is at https://docs.fashiolabs.com/llms.txt, and the complete reference in one file is at https://docs.fashiolabs.com/llms-full.txt.

From a product photo to a finished on-model image in four calls. This walkthrough uses `virtual_model` (Virtual Try-On); the same shape applies to every tool — see each tool's own page for its specific fields.

## 1\. Upload your product photo

Send raw image bytes (JPEG/PNG/WebP, max 8 MB) — get back a URL usable in the next step. You can skip this if your image is already hosted at a public URL.

**cURL**

```bash
curl -X POST https://api.fashiolabs.com/v1/uploads \
  -H "Authorization: Bearer fio_live_YOUR_KEY" \
  -H "Content-Type: image/jpeg" \
  --data-binary @dress.jpg
```

**Node.js**

```javascript
const bytes = await fs.readFile("dress.jpg");
const res = await fetch("https://api.fashiolabs.com/v1/uploads", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.FASHIO_API_KEY,
    "Content-Type": "image/jpeg",
  },
  body: bytes,
});
const { url } = await res.json();
```

**Response · 200**

```json
{
  "success": true,
  "id": "3f2a9e1c-...",
  "url": "https://firebasestorage.googleapis.com/v0/b/.../api_uploads%2F...jpg?alt=media&token=..."
}
```

## 2\. Pick a model, pose, venue (optional)

Browse the catalogs to get IDs for `fashion_model`, `pose` and `venue` — see [Core Endpoints](https://docs.fashiolabs.com/core-endpoints.md). Skip this and omit the fields for a clean studio default.

## 3\. Start the generation

**cURL**

```bash
curl -X POST https://api.fashiolabs.com/v1/generations \
  -H "Authorization: Bearer fio_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "toolId": "virtual_model",
    "images": {
      "fashion_model": "fm_south_asian_01",
      "garment_photo": "https://firebasestorage.googleapis.com/.../dress.jpg"
    },
    "ratio": "4:5"
  }'
```

**Node.js**

```javascript
const res = await fetch("https://api.fashiolabs.com/v1/generations", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.FASHIO_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    toolId: "virtual_model",
    images: {
      fashion_model: "fm_south_asian_01",
      garment_photo: url, // from step 1
    },
    ratio: "4:5",
  }),
});
const { id } = await res.json();
```

**Response · 202**

```json
{ "success": true, "id": "8b1e...", "status": "processing" }
```

## 4\. Poll for the result

Generation runs in the background. Poll every 2–3 seconds until `status` is `completed` or `failed`.

**cURL**

```bash
curl https://api.fashiolabs.com/v1/generations/8b1e... \
  -H "Authorization: Bearer fio_live_YOUR_KEY"
```

**Node.js**

```javascript
async function poll(id) {
  for (;;) {
    const res = await fetch(`https://api.fashiolabs.com/v1/generations/${id}`, {
      headers: { Authorization: "Bearer " + process.env.FASHIO_API_KEY },
    });
    const job = await res.json();
    if (job.status === "completed") return job.resultUrls;
    if (job.status === "failed") throw new Error(job.errorMessage);
    await new Promise((r) => setTimeout(r, 2000));
  }
}
```

**Response · 200 (completed)**

```json
{
  "success": true,
  "id": "8b1e...",
  "status": "completed",
  "resultUrls": ["https://.../result.jpg"],
  "errorMessage": null
}
```

> A failed generation automatically refunds the diamonds it charged — you never pay for a job that didn't finish.

---

Source: https://docs.fashiolabs.com/quickstart.html · OpenAPI spec: https://docs.fashiolabs.com/openapi.yaml · Docs index: https://docs.fashiolabs.com/llms.txt
