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

# AI Image Upscaler Tool - Magic Hour Docs

> Enhance image resolution and quality using AI-powered upscaling.

export const ToolSection = ({type = "image", outputs = [], title = "", productSlug = "", apiSlug = ""}) => <>
    {outputs && outputs.length > 0 && <Tabs>
        {outputs.map((output, idx) => <Tab key={idx} title={`Example Output ${idx + 1}`}>
            <Frame>
              {type === "video" ? <video controls preload="metadata" playsInline className="rounded-lg h-80" src={`${output.src}#t=0.001`} type={`${output.src?.endsWith("mp4") ? 'video/mp4' : "video/webm"}`}>
                </video> : type === "audio" ? <audio controls preload="metadata" className="w-full" src={output.src}>
                  Your browser does not support the audio element.
                </audio> : <img height="320" className="rounded-lg h-80" src={output.src} />}
            </Frame>
          </Tab>)}
      </Tabs>}

    <CardGroup cols={2}>
      <Card title="API Spec" icon="webhook" horizontal href={`/api-reference/${type}-projects/${apiSlug}`}>
        See API details
      </Card>
      <Card title="Product Page" icon="video" horizontal href={`https://magichour.ai/products/${productSlug}`}>
        Learn more about {title}
      </Card>
    </CardGroup>

  </>;

## Overview

AI Image Upscaler enhances image resolution and quality using AI-powered upscaling technology. The API increases image size while preserving and improving details, reducing artifacts, and maintaining visual fidelity at higher resolutions.

<ToolSection
  title="AI Image Upscaler"
  productSlug="ai-image-upscaler"
  apiSlug="ai-image-upscaler"
  type="image"
  outputs={[
{
  src: "/get-started/images/upscale-image-diff-1.jpg",
},
{
  src: "/get-started/images/upscale-image-diff-2.jpg",
},
]}
/>

## How It Works

1. **Provide a source image** - Upload the image you want to upscale
2. **Choose scale factor** - Select how much to increase resolution
3. **API enhances the image** - AI upscales while preserving and improving details
4. **Download the result** - Retrieve your high-resolution image

## Use Cases

* **Print preparation** - Enhance low-res images for print quality
* **E-commerce** - Improve product photo quality for web display
* **Photo restoration** - Upscale old or degraded images
* **Large format displays** - Prepare images for billboards or banners
* **Archive enhancement** - Improve historical or archival images

## Best Practices

### Input Image Quality

<Tip>
  **Start with the best quality available** - While AI upscaling is powerful, better input produces
  better output.
</Tip>

* **Avoid heavily compressed images** - JPEG artifacts will be amplified
* **Use original files when possible** - Avoid screenshots of screenshots
* **Check for existing blur** - AI can't recover details that aren't there

### Scale Factor Selection

| Scale Factor | Output Size         | Best For                          |
| :----------- | :------------------ | :-------------------------------- |
| 2x           | 2× width, 2× height | Minor enhancement, web use        |
| 4x           | 4× width, 4× height | Print preparation, large displays |

### Image Types That Upscale Well

✅ **Works great:**

* Photographs with clear subjects
* Artwork and illustrations
* Product images
* Portraits and faces

⚠️ **May have limitations:**

* Heavily compressed images (visible artifacts)
* Very blurry images
* Text-heavy images (use vector formats instead)

## Code Examples

### Basic 2x Upscaling

<CodeGroup>
  ```python Python theme={null}
  from magic_hour import Client
  from os import getenv

  client = Client(token=getenv("API_TOKEN"))

  result = client.v1.ai_image_upscaler.generate(
      assets={
          "image_file_path": "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/sea.jpg"
      },
      scale_factor=2.0,
      style={
          "enhancement": "Creative"
      },
      name="Image Upscaler image",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Upscale complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if hasattr(result, 'error_message'):
          print(f"Error: {result.error_message}")
  ```

  ```javascript Node.js theme={null}
  import { Client } from "magic-hour";

  const client = new Client({ token: process.env.API_TOKEN });

  const result = await client.v1.aiImageUpscaler.generate({
    assets: {
      imageFilePath: "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/sea.jpg",
    },
    scaleFactor: 2.0,
    style: {
      enhancement: "Balanced",
    },
    name: "Image Upscaler image",
    waitForCompletion: true,
    downloadOutputs: true,
    downloadDirectory: ".",
  });

  console.log(`✅ Upscale complete!`);
  console.log(`Status: ${result.status}`);
  console.log(`Downloaded to: ${result.downloadedPaths}`);
  console.log(`Credits charged: ${result.creditsCharged}`);
  ```
</CodeGroup>

### 4x Upscale

<CodeGroup>
  ```python Python theme={null}
  result = client.v1.ai_image_upscaler.generate(
      assets={
          "image_file_path": "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/eagle.jpg"
      },
      scale_factor=4.0,
      style={
          "enhancement": "Balanced"
      },
      name="Image Upscaler image",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Upscale complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if hasattr(result, 'error_message'):
          print(f"Error: {result.error_message}")
  ```

  ```javascript Node.js theme={null}
  const result = await client.v1.aiImageUpscaler.generate({
    assets: {
      imageFilePath: "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/sea.jpg",
    },
    scaleFactor: 4.0,
    style: {
      enhancement: "Balanced",
    },
    name: "Image Upscaler image",
    waitForCompletion: true,
    downloadOutputs: true,
    downloadDirectory: ".",
  });

  console.log(`✅ Upscale complete!`);
  console.log(`Status: ${result.status}`);
  console.log(`Downloaded to: ${result.downloadedPaths}`);
  console.log(`Credits charged: ${result.creditsCharged}`);
  ```
</CodeGroup>

## Pricing

| Scale Factor | Credits     |
| :----------- | :---------- |
| 2x upscale   | 50 credits  |
| 4x upscale   | 200 credits |

<Tip>
  **Try this in our Google Colab Cookbook:** [Run this API with sample
  code](https://colab.research.google.com/drive/1NTHL_lr_s-qBJ-mSecSXPzRLi9_V5JiU?usp=sharing). Just
  add your API key.
</Tip>

## API Reference

<Card title="AI Image Upscaler API Reference" icon="webhook" href="/api-reference/image-projects/ai-image-upscaler">
  View full API specification
</Card>

## Related Tools

<CardGroup cols={2}>
  <Card title="AI Image Generator" icon="wand-magic-sparkles" href="/tools/image/image-generator">
    Create images from text descriptions
  </Card>

  <Card title="Image Background Remover" icon="eraser" href="/tools/image/background-remover">
    Remove image backgrounds
  </Card>
</CardGroup>
