# Outfit Captioning

<figure><img src="/files/6mqKkzMxsArhlcAGxXGz" alt=""><figcaption></figcaption></figure>

## Upload outfit image

<mark style="color:green;">`POST`</mark> `https://prod.server.tryonlabs.ai/api/v1/experiment_image/`

Upload the outfit image before you create an experiment.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name         | Type         | Description                        |
| ------------ | ------------ | ---------------------------------- |
| `image`      | binary(file) | outfit image                       |
| `type`       | string       | specify 'garment'                  |
| `gender`     | string       | specify gender e.g. male or female |
| `preprocess` | string       | specify 'false'                    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "id": "xxxxxxxxxx",
    "image_url": "api/v1/ei/xxxxxxxxxx/d?token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
    "type": "garment",
    "gender": "female",
    "model_type": null,
    "garment_type": null,
    "garment_brand": "Unknown",
    "access": "private",
    "shopify_product_id": null,
    "shopify_product_handle": null,
    "preprocessing": "completed",
    "user": "xxxxxxxxxx"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## Create an experiment

<mark style="color:green;">`POST`</mark> `https://prod.server.tryonlabs.ai/api/v1/experiment/`

Create an experiment to trigger the caption generation.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name         | Type                       | Description                                                                         |
| ------------ | -------------------------- | ----------------------------------------------------------------------------------- |
| `action`     | caption\_outfit            | Please provide the experiment action. e.g. generate\_outfit, virtual\_try\_on, etc. |
| `params`     | {"output\_format": "json"} | Pass the parameters to use for generation.                                          |
| `garment_id` | xxxxxxxxxx                 | Provide the id of the garment uploaded in the last step                             |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "experiment": {
        "id": "xxxxxxxxxx",
        "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
        "output": null,
        "params": "{\"output_format\": \"json\"}",
        "aimodel": "outfit_ai",
        "action": "caption_outfit",
        "status": "pending",
        "store": null,
        "access": "private",
        "user_feedback": null,
        "redirect_count": 0,
        "model": null,
        "garment": {
            "id": "xxxxxxxxxx",
            "image_url": "api/v1/ei/xxxxxxxxxx/d?token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
            "type": "garment",
            "gender": "female",
            "model_type": null,
            "garment_type": null,
            "garment_brand": "Unknown",
            "access": "private",
            "shopify_product_id": null,
            "shopify_product_handle": null,
            "preprocessing": "completed",
            "user": "xxxxxxxxxx"
        },
        "result": null,
        "user": "xxxxxxxxxx",
        "results": []
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "failure",
    "message": "xx xxxx xxxx xxxx"
}
```

{% endtab %}
{% endtabs %}

## Check experiment status

<mark style="color:green;">`GET`</mark> `https://prod.server.tryonlabs.ai/api/v1/experiment/{id}/`

Call this endpoint to fetch an experiment containing the status and other details.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "experiment": {
        "id": "xxxxxxxxxx",
        "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
        "output": null,
        "params": "{\"output_format\": \"json\"}",
        "aimodel": "outfit_ai",
        "action": "caption_outfit",
        "status": "completed",
        "store": null,
        "access": "private",
        "user_feedback": null,
        "redirect_count": 0,
        "model": null,
        "garment": {
            "id": "xxxxxxxxxx",
            "image_url": "api/v1/ei/xxxxxxxxxx/d?token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
            "type": "garment",
            "gender": "female",
            "model_type": null,
            "garment_type": null,
            "garment_brand": "Unknown",
            "access": "private",
            "shopify_product_id": null,
            "shopify_product_handle": null,
            "preprocessing": "completed",
            "user": "xxxxxxxxxx"
        },
        "result": null,
        "user": "xxxxxxxxxx",
        "results": []
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "detail": "No Experiment matches the given query."
}
```

{% endtab %}
{% endtabs %}

## Fetch experiment to view the generated caption

<mark style="color:green;">`GET`</mark> `https://prod.server.tryonlabs.ai/api/v1/experiment/{id}/`

Call this endpoint to fetch an experiment containing the status and other details.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success",
    "experiment": {
        "id": "xxxxxxxxxx",
        "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
        "output": "{\"caption\": {\"color\": \"pink\", \"pattern\": \"solid\", \"style\": \"dress\", \"fit\": \"fitted\", \"type\": \"dress\", \"hemline\": \"A-line\", \"material\": \"cotton\", \"sleeve-length\": \"sleeveless\", \"fabric-elasticity\": \"stretchy\", \"neckline\": \"V-neck\", \"waistline\": \"fitted\"}}",
        "params": "{\"output_format\": \"json\"}",
        "aimodel": "outfit_ai",
        "action": "caption_outfit",
        "status": "completed",
        "store": null,
        "access": "private",
        "user_feedback": null,
        "redirect_count": 0,
        "model": null,
        "garment": {
            "id": "xxxxxxxxxx",
            "image_url": "api/v1/ei/xxxxxxxxxx/d?token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "created_on": "xxxx-xx-xxxxx:xx:xx.xxxxxxx",
            "type": "garment",
            "gender": "female",
            "model_type": null,
            "garment_type": null,
            "garment_brand": "Unknown",
            "access": "private",
            "shopify_product_id": null,
            "shopify_product_handle": null,
            "preprocessing": "completed",
            "user": "xxxxxxxxxx"
        },
        "result": null,
        "user": "xxxxxxxxxx",
        "results": []
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "detail": "No Experiment matches the given query."
}
```

{% endtab %}
{% endtabs %}

If the experiment status is 'completed', you'll see the caption output in JSON or text format. If the experiment fails, there won't be any output, and you might need to adjust some parameters to get the desired results.


---

# Agent Instructions: 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:

```
GET https://docs.tryonlabs.ai/outfit-captioning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
