# AI Image Upscaler (Real-ESRGAN) 2x 3x 4x (`roark/ai-image-upscaler`) Actor

Upscale images 2x, 3x or 4x with Real-ESRGAN AI. Removes JPEG artifacts and noise, sharpens edges, keeps transparency. Give image URLs, get high-resolution PNG/JPEG/WebP links. Pay only per upscaled image, never for failures.

- **URL**: https://apify.com/roark/ai-image-upscaler.md
- **Developed by:** [Dmitry Kvitka](https://apify.com/roark) (community)
- **Categories:** AI, Automation, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 image upscaleds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## AI Image Upscaler (Real-ESRGAN) — 2x / 3x / 4x

Upscale any image 2x, 3x or 4x with **Real-ESRGAN**, a neural super-resolution model. It removes JPEG artifacts and noise, sharpens edges and text, and keeps PNG/WebP transparency.

![Before and after: 240x160 JPEG upscaled 4x](https://api.apify.com/v2/key-value-stores/Qos1e2l3eRgbmcBnQ/records/before-after.jpg?signature=1g1KjIzpeq9z2qxhIP5Pn)

*Real run of this Actor: a 240×160 JPEG (NASA Earthrise, public domain). Left: ordinary bicubic 4x resize. Right: AI Upscaler 4x.*

Give a list of image URLs and get high-resolution PNG, JPEG or WebP files back. It works from the Console, the API, schedules, integrations (Make, Zapier, n8n) and AI agents over MCP.

### What it's good for

- Product photos and thumbnails that are too small for a marketplace listing
- Old or heavily compressed photos (removes blockiness from JPEG compression)
- Screenshots, logos and illustrations for print or retina screens
- Batch processing of whole image sets, such as scraped catalog images from another Actor

### Input

| Field | Description |
|---|---|
| `imageUrls` | Direct links to images (JPEG, PNG, WebP, BMP, GIF first frame). Up to 30 MB and 16 megapixels per image. |
| `scale` | `2`, `3` or `4` (default `4`) |
| `outputFormat` | `png` (default, lossless), `jpeg` or `webp` |

```json
{
  "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"],
  "scale": 4,
  "outputFormat": "png"
}
```

### Output

Each image becomes one dataset item. The upscaled file is in the run's key-value store, and `outputUrl` is a direct download link.

```json
{
  "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/upscaled-00000-93c8f889d3.png",
  "inputWidth": 172, "inputHeight": 178,
  "outputWidth": 688, "outputHeight": 712,
  "scale": 4, "format": "png", "chargedUnits": 1
}
```

If an image can't be downloaded or decoded, you get an item with an `error` field and are **not charged** for it.

### Use it from AI agents (MCP and x402)

This Actor works as a tool for AI agents with no extra setup:

- **MCP:** add `https://mcp.apify.com/?tools=roark/ai-image-upscaler` as a remote MCP server in Claude, Cursor, VS Code or any MCP client. The agent gets an `ai-image-upscaler` tool that takes image URLs.
- **x402 / agentic payments:** agents without an Apify account can run it and pay per image in USDC (see Apify's [agentic payments docs](https://docs.apify.com/integrations/x402)).
- **API:** `POST https://api.apify.com/v2/acts/roark~ai-image-upscaler/run-sync-get-dataset-items?token=<TOKEN>` with the JSON input above returns the results in one call.

### Pricing

Pay per image. One event covers an input image of up to 0.5 megapixels, which is most web images: 800×600 counts as one event. Larger inputs count one event per started 0.5 MP. You never pay for failed images, and the run stops cleanly when it reaches your spending limit.

### Model

Real-ESRGAN `realesr-general-x4v3` (BSD-3-Clause, © Xintao Wang et al.), running on CPU with ONNX Runtime and tiling, so large images don't run out of memory.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to images (JPEG, PNG, WebP, BMP, GIF first frame). Max 30 MB and 16 megapixels per input image.

## `scale` (type: `integer`):

Upscale factor: 2, 3 or 4.

## `outputFormat` (type: `string`):

PNG is lossless and keeps transparency; JPEG and WebP are smaller.

## Actor input object example

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
  ],
  "scale": 4,
  "outputFormat": "png"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("roark/ai-image-upscaler").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("roark/ai-image-upscaler").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
  ]
}' |
apify call roark/ai-image-upscaler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,roark/ai-image-upscaler"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/L6mnV1BbJ9rQM1bSR/builds/AkmnxAptfc1W9ho4H/openapi.json
