# Hairstyle Changer

Change your hairstyle in a photo.

## Description

Upload a photo and describe the desired hairstyle to generate a new image with the specified hairstyle applied.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/hairstyle-changer/change`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | Yes | Photo with the person (JPG, PNG, or WebP, max 10MB) |
| hairstyleDescription | string | Yes | Description of the desired hairstyle |
| aspectRatio | string | No | Desired aspect ratio for the output |

## Response

**200 OK**

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

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the generated 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=@photo.jpg" \
  -F "hairstyleDescription=Long wavy auburn hair" \
  -F "aspectRatio=1:1" \
  https://ps.codejar.net/api/hairstyle-changer/change
```

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