# Age Filter

Transform portrait images to show the person at a specific target age using AI.

## Description

Upload a portrait image and specify a target age (1-100). The AI will modify the person's appearance to show them at the specified age while preserving the background and setting.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/age-filter/filter`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | Yes | Input image (JPEG, PNG, or WebP, max 10MB) |
| targetAge | integer | Yes | Target age (1-100) |

## Response

**200 OK**

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

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the processed image with age-modified portrait |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | Invalid targetAge (must be 1-100) or no image provided |
| 402 | PAYMENT_REQUIRED | x402 payment not completed |
| 413 | FILE_TOO_LARGE | File exceeds 10MB limit |
| 415 | UNSUPPORTED_FORMAT | File type not allowed (only JPEG, PNG, WebP) |
| 500 | INTERNAL_ERROR | AI generation failed |
| 504 | AI_GENERATION_TIMEOUT | AI request timed out |

## Examples

### Transform to target age

```bash
npx x402-proxy -X POST \
  -F "image=@photo.jpg" \
  -F "targetAge=30" \
  https://ps.codejar.net/api/age-filter/filter
```

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

## Use Cases

- **Age Progression/Regression**: Show what someone might look like at a different age
- **Entertainment**: Fun age transformation effects
- **Forensics**: Age progression for missing persons
