# Predictions

### Changelog

> Jan 08, 2024
>
> Introducing new workflows [generate-qr-art-v5](https://docs.quickqr.art/apis/http-api-reference/predictions/generate-qr-art-v5 "mention") and [generate-qr-art-v5s](https://docs.quickqr.art/apis/http-api-reference/predictions/generate-qr-art-v5s "mention"):&#x20;
>
> 1. `generate_qr_art_v5`
> 2. `generate_qr_art_v5s`

> Dec 22:
>
> Introducing new workflows:&#x20;
>
> 1. [outpainting](https://docs.quickqr.art/apis/http-api-reference/predictions/outpainting "mention") allowing users to expand the boundaries of their images seamlessly.
> 2. `generate_qr_art_v4real` same as  `generate_qr_art_v4` but good at photo realistic style.
> 3. `generate_qr_art_v4niji` same as  `generate_qr_art_v4` but good at anime style.
> 4. `generate_qr_art_v4dream` same as  `generate_qr_art_v4` but good at photorealism without sacrificing range.

> Nov 28:
>
> Introducing a new workflow structure:
>
> 1. `generate_qr_art_v4`: This version is optimized for results similar to those seen on our homepage. It does not accept step parameters, and the credit cost is consistently set at 2.49 credits per image.
> 2. `generate_qr_art_v4s`: Tailored for both speed and cost-effectiveness, this version is available at a more economical rate of 1 credit per image.
>
> Body Update for v4 and beyond:
>
> * The field `qrImage` has been removed. In its place, a mandatory field `qrContent` has been introduced. From version 4 onwards, QR Art will be automatically generated based on the QR content you provide. It's no longer necessary to submit a Black and White QR Code.
> * A new feature, `isScannable`, has been added. This will verify the scannability of the output QR Code.
> * `batchSize` has been introduced, allowing the generation of up to 4 QR Art pieces in a single operation.

> Aug 28:
>
> * add new workflow: `generate_qr_art_v3a` & `generate_qr_art_v3b`

> Jul 30:
>
> * add new workflow: `generate_qr_art_v1.1` & `generate_qr_art_v2`
> * support `webhook` to get the final result of the prediction.&#x20;

> Jun 27:&#x20;
>
> * Update **List predictions** paginate response.
> * Change data type of `qrSteps` from `string` to `integer` (API create a prediction).
> * Instructions for NSFW case.

### Creating a prediction

## Create a QR Code Art.

<mark style="color:green;">`POST`</mark> `https://api.quickqr.art/v1/predictions/queue`

Creates a QR Code Art.

#### Headers

| Name                                        | Type   | Description    |
| ------------------------------------------- | ------ | -------------- |
| x-api-key<mark style="color:red;">\*</mark> | string | Your x-api-key |

#### Request Body

| Name                                        | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| qrImage<mark style="color:red;">\*</mark>   | string  | <p>URL of asset (in case of QR Art, this is the URL to your classic QR Code)</p><p><em><strong>Required field for versions(v1, v1.1, v2, v3a, v3b), for the remaining versions, please ignore this field.</strong></em> <a href="#example-for-v1-v1.1-v2-v3a-v3b"><em><strong>Example</strong></em></a></p>                                                                                                      |
| qrText<mark style="color:red;">\*</mark>    | string  | The prompt to generate                                                                                                                                                                                                                                                                                                                                                                                           |
| qrStrength                                  | float   | <p>QR Weight determines how much the final image will portray your QR.<br></p><p>Range: <code>0.0–3.0</code></p><p>Version 1, 1.1, 2, 3a, 3b</p><p>Default value:  <code>0.85</code></p><p>Version 4, 4s</p><p>Default value:  <code>1.5</code></p>                                                                                                                                                              |
| qrSteps                                     | integer | <p>Balance steps is how many time the image is sampled. More steps maybe more artistic but also reduce the QR scannability .</p><p>Version 1, 1.1, 2, 3a, 3b</p><p>Range: <code>10–20</code></p><p>Default value:  <code>16</code></p><p>Version 4s</p><p>Range:  <code>10-60</code></p><p>Default value:  <code>20</code></p>                                                                                   |
| seed                                        | integer | <p>Seed number to create a field of visual noise, similar to television static, as a starting point for generating the initial image grids.</p><p>Range: <code>0-9007199254740991</code></p><p>Default value: <code>random</code></p>                                                                                                                                                                            |
| negativePrompt                              | string  | The negative prompt (what you don't want to see in the generated images.)                                                                                                                                                                                                                                                                                                                                        |
| workflow<mark style="color:red;">\*</mark>  | string  | <p>Workflow that you want to run.</p><p>Get workflow name <a href="https://docs.quickqr.art/apis/http-api-reference/predictions#workflow-available">here</a></p>                                                                                                                                                                                                                                                 |
| webhook                                     | string  | An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the response body of the [get prediction](https://docs.quickqr.art/apis/http-api-reference/predictions#get-a-prediction) operation. If there are network problems, we will retry the webhook a few times, so make sure it can be safely called more than once. |
| qrContent<mark style="color:red;">\*</mark> | string  | <p>Content of QR (link, text, phone, email, ...)</p><p><strong>Required field for versions(v4, v4s),  </strong><em><strong>for the remaining versions, please ignore this field.</strong></em> <a href="#example-for-v4-v4s-v4dream-v4real-v4niji"><em><strong>Example</strong></em></a></p>                                                                                                                     |

{% tabs %}
{% tab title="200: OK AI-generated QR Art successfully created" %}

```json
{
   "success":true,
   "data":{
      "id":"",
      "userId":"",
      "createdAt":"2023-06-21T15:02:34.401Z",
      "startedAt":null,
      "updatedAt":"2023-06-21T15:02:34.401Z",
      "completedAt":null,
      "status":"queued",
      "input":{
         "workflow":"generate_qr_art",
         "qrStrength":0.85,
         "qrSteps":10,
         "seed":1000,
         "qrImage":"",
         "qrText":"a cute cat",
         "negativePrompt":""
      },
      "output":"",
      "error": null,
      "refunded":false,
      "creditType":"API_CREDITS",
      "isScanables": [
            true
        ],
      "credits":1
   }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}
{% endtabs %}

Note: Use `raw/json` body or use example `cURL` request:

#### Example for v4:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v4",
    "qrStrength": 1.5,
    "qrContent": "https://quickqr.art",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

#### Example for v4s:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v4s",
    "qrStrength": 1.5,
    "qrContent": "https://quickqr.art",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "qrSteps": 20,
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

Example for v4real:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v4real",
    "qrStrength": 1.5,
    "qrContent": "https://quickqr.art",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "qrSteps": 20,
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

Example for v4niji:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v4niji",
    "qrStrength": 1.5,
    "qrContent": "https://quickqr.art",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "qrSteps": 20,
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

Example for v4dream:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v4dream",
    "qrStrength": 1.5,
    "qrContent": "https://quickqr.art",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "qrSteps": 20,
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

#### Example for v1, v1.1, v2, v3a, v3b:

```bash
curl --location 'https://api.quickqr.art/v1/predictions/queue' \
--header 'x-api-key: <Insert your api key>' \
--header 'Content-Type: application/json' \
--data '{
    "workflow": "generate_qr_art_v1.1",
    "qrStrength": 1.5,
    "qrImage": "https://media.discordapp.net/attachments/1121322589256683670/1124532692797640775/qr.png?width=1152&height=1152",
    "qrText": "best quality, masterpiece, depth of field, beautiful woman, big dress, trees, flowers, sky, water",
    "negativePrompt": "",
    "qrSteps": 15,
    "seed": 2800163943969242,
    "webhook": ""
}
'
```

#### **Workflow available:**

* Version 1: **generate\_qr\_art**
* Version 1.1: **generate\_qr\_art\_v1.1**
* Version 2:  **generate\_qr\_art\_v2**
* Version 3a: **generate\_qr\_art\_v3a**
* Version 3b: **generate\_qr\_art\_v3b**
* Version 4: **generate\_qr\_art\_v4**
* Version 4s: **generate\_qr\_art\_v4s**
* Version 4real: **generate\_qr\_art\_v4real**
* Version 4niji: **generate\_qr\_art\_v4niji**
* Version 4dream: **generate\_qr\_art\_v4dream**
* Version 5: **generate\_qr\_art\_v5**
* Version 5s: **generate\_qr\_art\_v5s**

Read more version information [here](https://docs.quickqr.art/user-guide/parameter-list/version)

> If NSFW content is detected, the following error will be returned: "**NSFW content detected. Try running it again, or try a different prompt.**" Please note that credits will be deducted as GPU compute power is utilized. We kindly ask you to exercise caution when making requests and ensure that appropriate content filters are in place. For more information, please refer to our [Community Standards](https://docs.quickqr.art/getting-started/community-guidelines).

### Get a prediction

## Get a prediction

<mark style="color:blue;">`GET`</mark> `https://api.quickqr.art/v1/predictions/{prediction_id}`

Get a prediction

#### Path Parameters

| Name                                           | Type   | Description                               |
| ---------------------------------------------- | ------ | ----------------------------------------- |
| predictionId<mark style="color:red;">\*</mark> | string | The ID of the prediction you want to get. |

#### Headers

| Name                                        | Type   | Description    |
| ------------------------------------------- | ------ | -------------- |
| x-api-key<mark style="color:red;">\*</mark> | string | Your x-api-key |

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

```
{
   "success":true,
   "data":{
      "id":"",
      "userId":"",
      "createdAt":"2023-06-21T15:02:34.401Z",
      "startedAt":null,
      "updatedAt":"2023-06-21T15:02:34.401Z",
      "completedAt":null,
      "status":"queued",
      "input":{
         "workflow":"generate_qr_art",
         "qrStrength":0.85,
         "qrSteps":10,
         "seed":1000,
         "qrImage":"",
         "qrText":"a cute cat",
         "negativePrompt":""
      },
      "output":"",
      "error": null,
      "refunded":false,
      "creditType":"API_CREDITS",
      "isScanables": [
            true
        ],
      "credits":1,
   }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}
{% endtabs %}

Returns the same response as the create a prediction operation. `status` will be one of:

* `queued`: the prediction is starting up. If this status lasts longer than a few seconds, then it's typically because a new worker is being started to run the prediction.&#x20;
* `executing`: your QR Art is generating by our workers.&#x20;
* `executed`: the prediction completed successfully.&#x20;
* `failed`: the prediction encountered an error during processing.&#x20;

\
In the case of success, output will be an object containing the output of the QR Art. Any files will be represented as URLs.

In the case of failure, error will contain the error encountered during the prediction.

In the case of NSFW contents in your result, we will mark that prediction's status as `failed` and the output field will be `NSFW contents detected!`

### List predictions

## List predictions

<mark style="color:blue;">`GET`</mark> `https://api.quickqr.art/v1/predictions`

List predictions

#### Query Parameters

| Name   | Type    | Description   |
| ------ | ------- | ------------- |
| limit  | integer | Default: `10` |
| offset | integer | Default: `0`  |

#### Headers

| Name                                        | Type   | Description    |
| ------------------------------------------- | ------ | -------------- |
| x-api-key<mark style="color:red;">\*</mark> | string | Your x-api-key |

{% tabs %}
{% tab title="200: OK Return list of predictions" %}

```
{
   "data":{
      "docs":[
         {
            "userId":"",
            "status":"executed",
            "refunded":false,
            "creditType":"API_CREDITS",
            "credits":4,
            "output":"",
            "startedAt":"2023-06-27T09:14:52.746Z",
            "completedAt":"2023-06-27T09:15:09.212Z",
            "id":"",
            "input":{
               "workflow":"normal_work_flow",
               "qrStrength":0.6,
               "qrSteps":12,
               "qrImage":"",
               "qrText":"a man riding a cat",
               "negativePrompt":"",
               "seed":2345
            }
         }
      ],
      "totalDocs":1,
      "offset":0,
      "limit":10,
      "totalPages":1,
      "page":1,
      "pagingCounter":1,
      "hasPrevPage":false,
      "hasNextPage":false,
      "prevPage":null,
      "nextPage":null
   }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}
{% endtabs %}
