> For the complete documentation index, see [llms.txt](https://incubiq.gitbook.io/opensourceais/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://incubiq.gitbook.io/opensourceais/apis/ais/txt2img-and-img2img/ai_vqgan.md).

# ai\_vqgan

An authenticated client can post a request to VQGAN-CLIP

VQGAN-CLIP stands for  *Vector Quantized Generative Adversarial Network and Contrastive Language–Image Pre-training.* It is an ealier generation AI (pre 2020) for image to image processing

{% hint style="success" %}
This AI can run AI alongside a Daemon on GPU only
{% endhint %}

## Get the JSON config file for this AI

<mark style="color:blue;">`GET`</mark> `https://opensourceais.com/api/v1/public/config/vqgan`

{% tabs %}
{% tab title="200: OK The full JSON config file" %}

```json
{
    "engine": "vqgan",
    "name": "VQGAN-CLIP",
    "location": "",
    "ip": "0.0.0.0",
    "port": 5101,
    "version": "1.1.7",
    "description": "Text to Image",
    "github": "https://github.com/nerdyrodent/VQGAN-CLIP",
    "requiresGPU": true,
    "isFree": false,
    "default_cost": 1000,
    "params": [{
        "in": "word",
        "out": "-p",
        "isMandatory": true,
        "type": "string",
        "default": null,
        "ui": {
            "title": "Input (text and/or image)",
            "placeholder": "eg: gold coin from rome 100 BC, full size",
            "widget": "uiEdit",
            "column": 1
        }
    }, {
        "in": "url_upload",
        "out": "-filename",
        "isMandatory": false,
        "type": "string",
        "default": null,
        "accept": {
            "$max": 2048,
            "$ext": [".png", ".jpg", ".jpeg"]
        },
        "ui": {
            "widget": "uiSelectPicture",
            "column": 1
        }
    }, {
        "in": "steps",
        "out": "-i",
        "isMandatory": true,
        "type": "int",
        "default": 25,
        "freeAccess":  {"$max": 100},
        "ui": {
            "title": "Step Count",
            "tooltip": "",
            "min": 1,            
            "max": 200,            
            "unit": "",
            "widget": "uiRangeSlider",
            "column": 1
        }
    }, {
        "in": "saveinterval",
        "out": "-se",
        "isMandatory": true,
        "type": "int",
        "default": 20,
        "freeAccess":  {"$max": 20},
        "ui": {
            "title": "Save every",
            "tooltip": "",
            "min": 1,            
            "max": 20,            
            "unit": "",
            "widget": "uiRangeSlider",
            "column": 1
        }
    }, {
        "in": "width",
        "out": "-width",
        "isMandatory": true,
        "type": "int",
        "default": 384,
        "accept": {
            "$in":[320, 384, 448, 512, 576, 640, 704, 768],
            "display":["320x320", "384x384", "448x448", "512x512", "576x576", "640x640", "704x704", "768x768"]
        },
        "freeAccess":  {"$max": 512},
        "ui": {
            "title": "Output resolution",
            "widget": "uiMultiToggle",
            "unit": "px",    
            "column": 2,
            "autofill": [{"in":"height", "out":"-height"}]
        }
    }, {
        "in": "height",
        "out": "-height",
        "isMandatory": true,
        "type": "int",
        "default": 384,
        "accept": {"$in":[320, 384, 448, 512, 576, 640, 704, 768]},
        "freeAccess":  {"$max": 512},
        "ui": {
            "unit": "px"
        }
    }, {
        "in": "model",
        "out": "-ckpt",
        "isMandatory": false,
        "type": "string",
        "default": "vqgan_imagenet_f16_16384.ckpt"
    }, {
        "in": "yaml",
        "out": "-conf",
        "isMandatory": false,
        "type": "string",
        "default": "vqgan_imagenet_f16_16384.yaml"
    }, {
        "in": "output",
        "out": "-o",
        "isMandatory": true,
        "type": "function",
        "default": "$output_uid.ext"
    }]
}
```

{% endtab %}
{% endtabs %}

## Post a request to VQGAN via OpenSourceAIs

<mark style="color:green;">`POST`</mark> `https://opensourceais.com/api/v1/private/client/ai/vqgan`

#### Request Body

| Name                                   | Type   | Description                                                                                                                                                                                                  |
| -------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| width                                  | Number | The width of the output image. Defaults to 320                                                                                                                                                               |
| height                                 | Number | The height of the output image. Defaults to 320                                                                                                                                                              |
| steps                                  | Number | The number of steps requested for generating the output image. High number of steps cost more GPU compute. Defaults to 20. Should not exceed 200.                                                            |
| word<mark style="color:red;">\*</mark> | String | A text input to tell the AI what to generate.                                                                                                                                                                |
| url\_upload                            | String | A well formed URI starting with https\://... and accessing a PNG or JPG image. Note that if the image is not of the width and height size passed in parameters, it will be automatically cropped or resized. |
| saveinterval                           | Number | A positive number indicating when intermediate images are saved.                                                                                                                                             |
| model                                  | String | The model used for morphing the image.                                                                                                                                                                       |

{% tabs %}
{% tab title="201: Created Confirmation that the request was processed" %}

```json
{
    "data": {
        "uid": 1678361974000,
        "created_at": "2023-03-09T11:39:44.000Z"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request  This error should not happen unless authentication is tampered with" %}

```json
{
     data: null,
     status: 400,
     statusText: "A client token is required"
}
```

{% endtab %}

{% tab title="409: Conflict Could not add request to backlog" %}

```json
{
     data: null,
     status: 409,
     statusText: "Could not add to backlog"
}

```

{% endtab %}
{% endtabs %}
