> ## Documentation Index
> Fetch the complete documentation index at: https://docs.livepeer.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Upscale

## Overview

The Livepeer AI network's `upscale` pipeline provides **advanced image
upscaling**. Powered by the latest diffusion models in HuggingFace's
[super-resolution](https://huggingface.co/docs/diffusers/en/api/pipelines/stable_diffusion/upscale)
pipeline, it enhances the resolution of input images by a factor of 4.

<div align="center">
  ```mermaid theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  graph LR
      A[<div style="width: 128px;"><img src="https://mintlify.s3-us-west-1.amazonaws.com/na-36/images/ai/cool-cat-low-res.png" alt="Image of low resolution cat"/></div>] --> B[Gateway]
      P[A white cat wearing sunglasses on the beach] --> B
      B --> C[Orchestrator]
      C --> B
      B --> D[<div style="width: 200px;"><img src="https://mintlify.s3-us-west-1.amazonaws.com/na-36/images/ai/cool-cat.png" alt="Image of high resolution cat"/></div>]
  ```
</div>

## Models

### Warm Models

The current warm model requested for the `upscale` pipeline is:

* [stabilityai/stable-diffusion-x4-upscaler](https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler):
  A text-guided upscaling diffusion model trained on large LAION images,
  offering enhanced resolution and controlled noise addition.

<Tip>
  For faster responses with different
  [upscale](https://huggingface.co/docs/diffusers/en/api/pipelines/stable_diffusion/upscale)
  compatible diffusion models, ask Orchestrators to load it on their GPU via the
  `ai-video` channel in [Discord Server](https://discord.gg/livepeer).
</Tip>

### On-Demand Models

The following models have been tested and verified for the `upscale` pipeline:

<Note>
  If a specific model you wish to use is not listed, please submit a [feature
  request](https://github.com/livepeer/ai-worker/issues/new?assignees=\&labels=enhancement%2Cmodel\&projects=\&template=model_request.yml)
  on GitHub to get the model verified and added to the list.
</Note>

<Accordion title="Tested and Verified Diffusion Models">
  * [stabilityai/stable-diffusion-x4-upscaler](https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler):
    A text-guided upscaling diffusion model trained on large LAION images,
    offering enhanced resolution and controlled noise addition.
</Accordion>

## Basic Usage Instructions

<Tip>
  For a detailed understanding of the `upscale` endpoint and to experiment with
  the API, see the [Livepeer AI API Reference](/ai/api-reference/upscale).
</Tip>

To generate an image with the `upscale` pipeline, send a `POST` request to the
Gateway's `upscale` API endpoint:

```bash theme={"theme":{"light":"github-light","dark":"dark-plus"}}
curl -X POST https://<GATEWAY_IP>/upscale \
    -F model_id="stabilityai/stable-diffusion-x4-upscaler" \
    -F image=@<PATH_TO_IMAGE>/low_res_cat.png \
    -F prompt="A white cat"
```

In this command:

* `<GATEWAY_IP>` should be replaced with your AI Gateway's IP address.
* `model_id` is the diffusion model for image generation.
* The `image` field holds the **absolute** path to the image file to be
  upscaled.
* `prompt` is a descriptive text that provides context about the content of the
  image.

For additional optional parameters, refer to the
[Livepeer AI API Reference](/ai/api-reference/upscale).

After execution, the Orchestrator processes the request and returns the response
to the Gateway:

```json theme={"theme":{"light":"github-light","dark":"dark-plus"}}
{
  "images": [
    {
      "nsfw": false,
      "seed": 3197613440,
      "url": "https://<GATEWAY_IP>/stream/dd5ad78d/7adde483.png"
    }
  ]
}
```

The `url` in the response is the URL of the generated image. Download the image
with:

```bash theme={"theme":{"light":"github-light","dark":"dark-plus"}}
curl -O "https://<GATEWAY_IP>/stream/dd5ad78d/7adde483.png"
```

## Orchestrator Configuration

To configure your Orchestrator to serve the `upscale` pipeline, refer to the
[Orchestrator Configuration](/ai/orchestrators/get-started) guide.

### System Requirements

The following system requirements are recommended for optimal performance:

* [NVIDIA GPU](https://developer.nvidia.com/cuda-gpus) with **at least 24GB** of
  VRAM.

## Recommended Pipeline Pricing

<Note>
  We are planning to simplify the pricing in the future so orchestrators can set
  one AI price per compute unit and have the system automatically scale based on
  the model's compute requirements.
</Note>

The pricing for the `upscale` pipeline is based on competitor pricing. However,
we strongly encourage orchestrators to set their own pricing based on their
costs and requirements. Setting a competitive price will help attract more jobs,
as Gateways can set their maximum price for a job. The current recommended
pricing for this pipeline is `1.9073484e-08 USD` per **input pixel**
(`height * width`).

## API Reference

<Card title="API Reference" icon="rectangle-terminal" href="/ai/api-reference/upscale">
  Explore the `upscale` endpoint and experiment with the API in the Livepeer AI
  API Reference.
</Card>
