# Photo Restoration

Restore old, damaged, or low-quality photos.

## Description

Upload a photo that needs restoration and optionally provide specific instructions for the restoration process.

## Authentication

**Required**: x402 payment

This endpoint requires payment via the x402 protocol. See the [Setup](./setup.md) for setup instructions.

## Request

**Endpoint**: `POST /api/photo-restoration/restore`

**Content-Type**: `multipart/form-data`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | Yes | Photo to restore (JPG, PNG, or WebP, max 10MB) |
| restorationInstructions | string | No | Specific instructions for restoration |
| outputFormat | string | No | Output format: `png` (default) or `webp` |

## Response

**200 OK**

```json
{
  "imageUrl": "/outputs/uuid-here.png"
}
```

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the restored image |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | Invalid request parameters |
| 402 | PAYMENT_REQUIRED | x402 payment not completed |
| 413 | FILE_TOO_LARGE | File exceeds 10MB limit |
| 415 | UNSUPPORTED_FORMAT | Invalid file type (must be JPG, PNG, or WebP) |
| 422 | INVALID_IMAGE_DATA | Unable to process image |
| 500 | INTERNAL_ERROR | AI generation failed |
| 504 | AI_GENERATION_TIMEOUT | AI request timed out |

## Example

```bash
npx x402-proxy -X POST \
  -F "image=@old-photo.jpg" \
  -F "restorationInstructions=Fix scratches and restore colors" \
  -F "outputFormat=png" \
  https://ps.codejar.net/api/photo-restoration/restore
```

**Response:**
```json
{
  "imageUrl": "/outputs/550e8400-e29b-41d4-a716-446655440001.png"
}
```
