# Style Transfer

Apply artistic styles to images using AI.

## Description

Upload a content image and optionally provide a style reference image or a text description of the desired artistic style. The AI transforms the content image to match the specified style while preserving the original composition and structure. Supports styles like Van Gogh Starry Night, watercolor painting, oil painting, impressionist, and more.

If no style image or description is provided, the image will be transformed using a default artistic painting style with vibrant colors and expressive brushstrokes.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/style-transfer/transfer`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| content | file | Yes | The image to apply the style to (JPEG, PNG, or WebP, max 10MB) |
| style | file | No | Reference style image (JPEG, PNG, or WebP, max 10MB) |
| styleDescription | string | No | Text description of the desired style, e.g. "Van Gogh Starry Night", "watercolor painting", "oil painting", "impressionist" |

## Response

**200 OK**

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

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

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | No content 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 |

## Example

### With style description

```bash
npx x402-proxy -X POST \
  -F "content=@landscape.jpg" \
  -F "styleDescription=Van Gogh Starry Night" \
  https://ps.codejar.net/api/style-transfer/transfer
```

### With style reference image

```bash
npx x402-proxy -X POST \
  -F "content=@landscape.jpg" \
  -F "style=@starry-night.jpg" \
  https://ps.codejar.net/api/style-transfer/transfer
```

### Default artistic style (no style specified)

```bash
npx x402-proxy -X POST \
  -F "content=@landscape.jpg" \
  https://ps.codejar.net/api/style-transfer/transfer
```

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

## Use Cases

- **Artistic Transformation**: Convert photos into paintings inspired by famous artists
- **Creative Projects**: Apply watercolor, oil painting, or sketch styles to images
- **Social Media Content**: Create unique stylized images for posts and stories
- **Interior Decor**: Preview how artwork would look in different artistic styles
