> For the complete documentation index, see [llms.txt](https://dressx.gitbook.io/dressx-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dressx.gitbook.io/dressx-docs/virtual-try-on/model-to-garment.md).

# Model To Garment

***

### API key.

To use the DRESSX paywall API, you need an API key. Please fallow this Authentication [link](/dressx-docs/getting-started/authentication.md) for more deteils

#### Create a ghost mannequin or flat lay product image

Endpoint: `POST https://api.dressxagent.com/api_paywall/model_to_gament/`

Authentication: Required. Send your API key in the header:

* `Api-Key: <your_api_key>`
* or `X-Api-Key: <your_api_key>`

Content-Type: `multipart/form-data`

This endpoint creates an asynchronous image generation task. It accepts a photo that may contain a person wearing clothing or visible product items, then generates either a clean ghost mannequin product photo or a flat lay product photo.

Note: Either `avatar_url` / `image_url` OR `avatar_file` / `image_file` is required. Provide one image input.

**Required**

| Parameter                     | Type   | Description                                                                                                            |
| ----------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------- |
| `avatar_url` or `image_url`   | String | URL of the input photo. The photo may show a person wearing the garment or product items. One image input is required. |
| `avatar_file` or `image_file` | File   | File upload alternative to `avatar_url` / `image_url`. One image input is required.                                    |
| `output_type`                 | String | Required output mode. Supported values: `ghost` or `flatlay`.                                                          |

**Optional**

| Parameter    | Type   | Description                                                                                                       |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------- |
| `resolution` | String | Output image size. Supported values: `1K`, `2K`. Default: `1K`.                                                   |
| `source`     | String | Optional source/client identifier. For paywall calls, the API key owner's email is used as source when available. |

**Output types**

| Value     | Result                                                                                                                            |
| --------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `ghost`   | Creates a ghost mannequin e-commerce product photo. The product keeps a worn shape/volume, but no person or mannequin is visible. |
| `flatlay` | Creates a flat lay e-commerce product photo. The product is laid flat on a clean neutral studio background.                       |

**File uploads**

When using `avatar_file` / `image_file` instead of a URL:

* Supported formats follow the platform upload limits.
* Field name can be `avatar_file` or `image_file`.
* The uploaded file is first stored on the DRESSX file service, then processed asynchronously.

***

#### Request examples

**Example 1: Ghost mannequin with image URL**

```bash
curl -X POST 'https://api.dressxagent.com/api_paywall/model_to_gament/' \
  -H 'Api-Key: your-secret-api-key-here' \
  -F 'image_url=https://example.com/model-wearing-jacket.jpg' \
  -F 'output_type=ghost' \
  -F 'resolution=1K'
```

**Example 2: Flat lay with file upload**

```bash
curl -X POST 'https://api.dressxagent.com/api_paywall/model_to_gament/' \
  -H 'Api-Key: your-secret-api-key-here' \
  -F 'image_file=@/path/to/model-wearing-dress.jpg' \
  -F 'output_type=flatlay'
```

**Example 4: JavaScript / Fetch**

```javascript
const formData = new FormData();
formData.append('image_file', fileInput.files[0]);
formData.append('output_type', 'flatlay');
formData.append('resolution', '1K');

const response = await fetch('https://api.dressxagent.com/api_paywall/model_to_gament/', {
  method: 'POST',
  headers: { 'Api-Key': 'your-secret-api-key-here' },
  body: formData,
});

const result = await response.json();
```

***

#### Response

**Task created (200 OK)**

```json
{
  "status": "ok",
  "data": {
    "tryon_id": "8c508b24-9a95-4f56-bf5d-0b43c4e0e000",
    "status": "created",
    "model_image_url": "https://...",
    "output_type": "flatlay"
  }
}
```

Use `tryon_id` to poll for completion and the result image.

***

#### Polling

Poll the returned `tryon_id` until `data.status` becomes `success` or `failed`.

Endpoint: `GET https://api.dressxagent.com/api/vb_ai_predict_get/<tryon_id>/`

```bash
curl -X GET 'https://api.dressxagent.com/api/vb_ai_predict_get/8c508b24-9a95-4f56-bf5d-0b43c4e0e000/'
```

**Processing response**

```json
{
  "status": "ok",
  "data": {
    "tryon_id": "8c508b24-9a95-4f56-bf5d-0b43c4e0e000",
    "status": "processing",
    "dressed_image": "",
    "model_image_url": "https://..."
  }
}
```

**Success response**

```json
{
  "status": "ok",
  "data": {
    "tryon_id": "8c508b24-9a95-4f56-bf5d-0b43c4e0e000",
    "status": "success",
    "dressed_image": "https://cdn.example.com/generated-flatlay.png",
    "model_image_url": "https://..."
  }
}
```

The generated image URL is returned in `data.dressed_image`.

***

#### Error responses

Missing API key or invalid API key (401 Unauthorized)

```json
{
  "status": "error",
  "message": "API key required or invalid"
}
```

Insufficient balance (402 Payment Required)

```json
{
  "status": "error",
  "message": "Insufficient balance",
  "required_usd": "0.05",
  "balance_usd": "0.00"
}
```

Missing image input (400 Bad Request)

```json
{
  "status": "error",
  "message": "avatar_url/image_url or avatar_file/image_file required"
}
```

Missing or invalid output type (400 Bad Request)

```json
{
  "status": "error",
  "message": "output_type is required and must be one of: ghost, flatlay"
}
```

Method not allowed (405 Method Not Allowed)

```json
{
  "status": "error",
  "message": "Method not allowed"
}
```

***

#### Task failure states

If generation fails, polling may return `data.status = "failed"`. Common internal reasons include:

| Reason           | Meaning                                                                       |
| ---------------- | ----------------------------------------------------------------------------- |
| `Too Sexy`       | The image model returned no generated image, usually due to safety filtering. |
| `Generation`     | The image could not be generated or downloaded.                               |
| `No input image` | The input image URL could not be downloaded.                                  |
| `Not valid`      | Validation was enabled and the input image did not pass validation.           |

***

#### Usage notes

| Topic          | Notes                                                                                                  |
| -------------- | ------------------------------------------------------------------------------------------------------ |
| Authentication | Always include the `Api-Key` or `X-Api-Key` header.                                                    |
| Request type   | Use `multipart/form-data`.                                                                             |
| Output mode    | Send `output_type=ghost` for ghost mannequin or `output_type=flatlay` for flat lay.                    |
| Async flow     | The create endpoint returns immediately. Poll `vb_ai_predict_get/<tryon_id>/` for the generated image. |
| Balance        | The paywall endpoint charges per request; ensure sufficient balance.                                   |
| Version        | Generated tasks use model version `5.52`.                                                              |

***

Contact: For API key requests or support, contact your API administrator.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dressx.gitbook.io/dressx-docs/virtual-try-on/model-to-garment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
