# Sprite Sheet Generator

Generate 3x3 sprite sheets for 2D game characters.

## Description

Upload a character image or describe a character to generate a 3x3 sprite sheet with animation frames. Supports various animation types like idle, walk, run, jump, attack, and defend.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/sprite-sheet-generator/generate`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | No | Character reference image (JPG, PNG, or WebP, max 10MB) |
| characterDescription | string | No | Text description of the character, e.g., "robot warrior", "cute anime girl" |
| sheetType | string | No | Animation type: `idle` (default), `walk`, `run`, `jump`, `attack`, `defend` |

> **Note**: At least one of `image` or `characterDescription` should be provided for best results.

## Response

**200 OK**

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

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the generated sprite sheet |

## 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=@character.png" \
  -F "characterDescription=robot warrior" \
  -F "sheetType=walk" \
  https://ps.codejar.net/api/sprite-sheet-generator/generate
```

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