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

# Image Upscaling

> Enhance and upscale images using AI-powered super-resolution models with detail preservation

Enhance image resolution and quality using advanced AI upscaling models. Perfect for improving low-resolution images, old photos, or generated content that needs higher quality.

## Request Body

**imageUrl** `string`

Public URL of the image to upscale (HTTPS required)

**imageBase64** `string`

Base64-encoded image data (alternative to imageUrl)

**upscaleFactor** `integer` (default: 2)

Upscaling factor: `2` (2x), `4` (4x), or `8` (8x) the original resolution

**model** `string` (default: real-esrgan)

Upscaling model to use:

* `real-esrgan` - Best for general images and photos
* `real-esrgan-anime` - Optimized for anime/cartoon images
* `esrgan-plus` - Enhanced model for photorealistic images
* `waifu2x` - Specialized for anime artwork and illustrations
* `srcnn` - Fast upscaling with good detail preservation

**enhanceMode** `string` (default: standard)

Enhancement mode:

* `standard` - Balanced quality and speed
* `high_quality` - Maximum quality, slower processing
* `fast` - Quick processing, good for previews
* `face_enhance` - Specialized for faces and portraits

**denoiseStrength** `number` (default: 0.5)

Noise reduction strength (0.0 to 1.0). Higher values remove more noise but may reduce detail.

**preserveDetails** `boolean` (default: true)

Whether to preserve fine details and textures during upscaling

**outputFormat** `string` (default: png)

Output image format: `png`, `jpg`, `webp`

**jpegQuality** `integer` (default: 95)

JPEG quality (1-100, only used when outputFormat is 'jpg')

## Response

**upscaleId** `string`

Unique identifier for the upscaling job

**status** `string`

Processing status: `queued`, `processing`, `completed`, `failed`

**originalImage** `object`

Information about the original image

**Original Image**

**width** `integer`

Original image width

**height** `integer`

Original image height

**format** `string`

Original image format

**fileSize** `string`

Original file size (e.g., "2.1MB")

**upscaledImage** `object`

Information about the upscaled image (available when completed)

**Upscaled Image**

**url** `string`

URL to download the upscaled image

**width** `integer`

Upscaled image width

**height** `integer`

Upscaled image height

**format** `string`

Output image format

**fileSize** `string`

Upscaled file size

**downloadUrl** `string`

Pre-signed download URL (expires in 24 hours)

**processingDetails** `object`

Processing information

**Processing Details**

**model** `string`

Model used for upscaling

**upscaleFactor** `integer`

Applied upscaling factor

**processingTime** `number`

Time taken to process in seconds

**estimatedTime** `string`

Estimated completion time (when processing)

## Example

```bash cURL
curl -X POST "https://api.tensorone.ai/v2/ai/image-upscale" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "imageUrl": "https://example.com/low-res-photo.jpg",
    "upscaleFactor": 4,
    "model": "real-esrgan",
    "enhanceMode": "high_quality",
    "denoiseStrength": 0.6,
    "outputFormat": "png"
  }'
```

```python Python
import requests
import base64
from PIL import Image
import io

# Method 1: Upscale from URL
def upscale_image_from_url(image_url, upscale_factor=4):
    response = requests.post(
        "https://api.tensorone.ai/v2/ai/image-upscale",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json={
            "imageUrl": image_url,
            "upscaleFactor": upscale_factor,
            "model": "real-esrgan",
            "enhanceMode": "high_quality",
            "preserveDetails": True,
            "outputFormat": "png"
        }
    )
    return response.json()

# Method 2: Upscale from local file
def upscale_local_image(image_path, upscale_factor=2):
    # Read and encode image
    with open(image_path, 'rb') as image_file:
        image_data = base64.b64encode(image_file.read()).decode('utf-8')
    
    response = requests.post(
        "https://api.tensorone.ai/v2/ai/image-upscale",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json={
            "imageBase64": image_data,
            "upscaleFactor": upscale_factor,
            "model": "real-esrgan",
            "enhanceMode": "standard",
            "denoiseStrength": 0.5
        }
    )
    return response.json()

# Start upscaling
result = upscale_image_from_url("https://example.com/photo.jpg", 4)
upscale_id = result['upscaleId']

print(f"Upscaling started: {upscale_id}")
print(f"Original: {result['originalImage']['width']}x{result['originalImage']['height']}")

# Poll for completion
import time

while True:
    status_response = requests.get(
        f"https://api.tensorone.ai/v2/ai/upscale/{upscale_id}/status",
        headers={"Authorization": "Bearer YOUR_API_KEY"}
    )
    
    status = status_response.json()
    
    if status['status'] == 'completed':
        upscaled = status['upscaledImage']
        print(f"Completed! New resolution: {upscaled['width']}x{upscaled['height']}")
        print(f"Download URL: {upscaled['downloadUrl']}")
        
        # Download the upscaled image
        download_response = requests.get(upscaled['downloadUrl'])
        with open('upscaled_image.png', 'wb') as f:
            f.write(download_response.content)
        
        break
    elif status['status'] == 'failed':
        print(f"Upscaling failed: {status.get('error', 'Unknown error')}")
        break
    else:
        print(f"Status: {status['status']}")
        time.sleep(10)
```

```javascript JavaScript
const fs = require('fs');

// Upscale image from URL
const upscaleImage = async (imageUrl, upscaleFactor = 2) => {
  const response = await fetch('https://api.tensorone.ai/v2/ai/image-upscale', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      imageUrl: imageUrl,
      upscaleFactor: upscaleFactor,
      model: 'real-esrgan',
      enhanceMode: 'standard',
      outputFormat: 'webp'
    })
  });

  const result = await response.json();
  return result;
};

// Monitor upscaling progress
const monitorUpscaling = async (upscaleId) => {
  while (true) {
    const statusResponse = await fetch(`https://api.tensorone.ai/v2/ai/upscale/${upscaleId}/status`, {
      headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
    });
    
    const status = await statusResponse.json();
    
    if (status.status === 'completed') {
      console.log('Upscaling completed!');
      console.log('Download URL:', status.upscaledImage.downloadUrl);
      return status;
    }
    
    console.log('Status:', status.status);
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
};

// Usage
(async () => {
  try {
    const result = await upscaleImage('https://example.com/image.jpg', 4);
    console.log('Upscaling started:', result.upscaleId);
    
    const completed = await monitorUpscaling(result.upscaleId);
    console.log('Final result:', completed);
  } catch (error) {
    console.error('Error:', error);
  }
})();
```

```json Response
{
  "upscaleId": "ups_abc123_def456",
  "status": "processing",
  "originalImage": {
    "width": 512,
    "height": 384,
    "format": "jpg",
    "fileSize": "245KB"
  },
  "processingDetails": {
    "model": "real-esrgan",
    "upscaleFactor": 4,
    "estimatedTime": "45-60 seconds"
  },
  "createdAt": "2024-01-16T15:30:00Z"
}
```

```json Completed Response
{
  "upscaleId": "ups_abc123_def456",
  "status": "completed",
  "originalImage": {
    "width": 512,
    "height": 384,
    "format": "jpg",
    "fileSize": "245KB"
  },
  "upscaledImage": {
    "url": "https://upscaled.tensorone.ai/ups_abc123_def456.png",
    "width": 2048,
    "height": 1536,
    "format": "png",
    "fileSize": "8.2MB",
    "downloadUrl": "https://upscaled.tensorone.ai/download/ups_abc123_def456?expires=..."
  },
  "processingDetails": {
    "model": "real-esrgan",
    "upscaleFactor": 4,
    "processingTime": 52.3
  },
  "createdAt": "2024-01-16T15:30:00Z",
  "completedAt": "2024-01-16T15:30:52Z"
}
```

## Specialized Use Cases

### Photo Restoration

Restore old or damaged photos:

```python
restoration_response = requests.post(
    "https://api.tensorone.ai/v2/ai/image-upscale",
    json={
        "imageUrl": "https://example.com/old-photo.jpg",
        "upscaleFactor": 2,
        "model": "real-esrgan",
        "enhanceMode": "face_enhance",  # Good for portraits
        "denoiseStrength": 0.8,  # Remove artifacts from old photos
        "preserveDetails": True
    }
)
```

### Anime/Artwork Enhancement

Optimize for anime and illustrations:

```python
anime_response = requests.post(
    "https://api.tensorone.ai/v2/ai/image-upscale",
    json={
        "imageUrl": "https://example.com/anime-art.png",
        "upscaleFactor": 4,
        "model": "real-esrgan-anime",  # Specialized for anime
        "enhanceMode": "high_quality",
        "denoiseStrength": 0.3,  # Lower noise reduction for clean art
        "outputFormat": "png"  # Preserve transparency
    }
)
```

### Batch Processing

Upscale multiple images:

```python
image_urls = [
    "https://example.com/image1.jpg",
    "https://example.com/image2.jpg", 
    "https://example.com/image3.jpg"
]

upscale_jobs = []

for url in image_urls:
    response = requests.post(
        "https://api.tensorone.ai/v2/ai/image-upscale",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        json={
            "imageUrl": url,
            "upscaleFactor": 2,
            "model": "real-esrgan",
            "enhanceMode": "fast"  # Faster for batch processing
        }
    )
    
    upscale_jobs.append(response.json()['upscaleId'])

print(f"Started {len(upscale_jobs)} upscaling jobs")

# Monitor all jobs
def check_all_jobs(job_ids):
    completed = []
    for job_id in job_ids:
        status_response = requests.get(
            f"https://api.tensorone.ai/v2/ai/upscale/{job_id}/status",
            headers={"Authorization": "Bearer YOUR_API_KEY"}
        )
        status = status_response.json()
        
        if status['status'] == 'completed':
            completed.append(status)
    
    return completed

# Wait for all to complete
import time
while len(check_all_jobs(upscale_jobs)) < len(upscale_jobs):
    print(f"Completed: {len(check_all_jobs(upscale_jobs))}/{len(upscale_jobs)}")
    time.sleep(15)

print("All upscaling jobs completed!")
```

## Quality Comparison

Compare results from different models:

```python
def compare_models(image_url):
    models = ['real-esrgan', 'real-esrgan-anime', 'esrgan-plus', 'waifu2x']
    results = {}
    
    for model in models:
        response = requests.post(
            "https://api.tensorone.ai/v2/ai/image-upscale",
            headers={"Authorization": "Bearer YOUR_API_KEY"},
            json={
                "imageUrl": image_url,
                "upscaleFactor": 2,
                "model": model,
                "enhanceMode": "standard"
            }
        )
        
        results[model] = response.json()['upscaleId']
    
    return results

# Compare different models on same image
comparison = compare_models("https://example.com/test-image.jpg")
print("Model comparison started:", comparison)
```

## Advanced Options

### Custom Enhancement Pipeline

Chain multiple enhancements:

```python
# Step 1: Upscale
upscale_response = requests.post(
    "https://api.tensorone.ai/v2/ai/image-upscale",
    json={
        "imageUrl": "https://example.com/image.jpg",
        "upscaleFactor": 2,
        "model": "real-esrgan"
    }
)

upscale_id = upscale_response.json()['upscaleId']

# Wait for completion, then enhance further
# ... wait for completion ...

# Step 2: Apply additional enhancement
enhance_response = requests.post(
    "https://api.tensorone.ai/v2/ai/image-enhance",
    json={
        "imageUrl": completed_upscale['upscaledImage']['url'],
        "enhanceType": "detail_boost",
        "strength": 0.7
    }
)
```

### Face-Specific Enhancement

Enhanced processing for portraits:

```python
face_enhance_response = requests.post(
    "https://api.tensorone.ai/v2/ai/image-upscale",
    json={
        "imageUrl": "https://example.com/portrait.jpg",
        "upscaleFactor": 4,
        "model": "real-esrgan",
        "enhanceMode": "face_enhance",
        "faceEnhancement": {
            "enabled": True,
            "skinSmoothing": 0.3,
            "eyeSharpening": 0.8,
            "detailPreservation": 0.9
        }
    }
)
```

## Supported Image Formats

### Input Formats

* **JPEG/JPG**: Universal support, good for photos
* **PNG**: Transparency preserved, good for graphics
* **WebP**: Modern format with good compression
* **BMP**: Basic bitmap format
* **TIFF**: High-quality format support

### Output Formats

* **PNG**: Best quality, supports transparency
* **JPEG**: Smaller file size, good for photos
* **WebP**: Modern format with excellent compression

## Limitations and Guidelines

### File Size Limits

* **Maximum input size**: 50MB per image
* **Maximum resolution**: 16K x 16K pixels for input
* **Processing time**: Varies by size and upscale factor

### Best Practices

* **Choose the right model**: Real-ESRGAN for photos, Waifu2x for anime
* **Start with 2x upscaling**: Test before going to 4x or 8x
* **Consider file size**: Higher upscale factors create much larger files
* **Format selection**: Use PNG for quality, JPEG for smaller files
* **Noise reduction**: Adjust based on input image quality

## Pricing

* **2x Upscaling**: \$0.05 per megapixel of output
* **4x Upscaling**: \$0.10 per megapixel of output
* **8x Upscaling**: \$0.20 per megapixel of output
* **Face Enhancement**: Additional \$0.02 per face detected
* **Batch Processing**: 10% discount for 10+ images

> [!NOTE]
>
> Processing time depends on image size and upscale factor. Typical times: 2x (10-30s), 4x (30-90s), 8x (60-180s).

> [!WARNING]
>
> Very large upscale factors (8x) can create files over 100MB. Consider your storage and bandwidth requirements when choosing upscale factors.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.