# HDRI Generator

Generate equirectangular 360-degree panoramic environment maps for Three.js.

## Description

Generate seamless equirectangular environment images optimized for use as 360° panoramic backgrounds in Three.js. The left and right edges connect flawlessly for seamless wrap-around viewing.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/hdri-generator/generate`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| prompt | string | Yes | Description of the environment (e.g., "A serene sunset over mountains") |

## Response

**200 OK**

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

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the generated HDRI image (21:9 aspect ratio, ~1024x439 pixels) |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | Missing or invalid prompt |
| 402 | PAYMENT_REQUIRED | x402 payment not completed |
| 422 | INVALID_IMAGE_DATA | AI response contained no image |
| 500 | INTERNAL_ERROR | AI generation failed |
| 504 | AI_GENERATION_TIMEOUT | AI request timed out |

## Example

```bash
npx x402-proxy -X POST \
  -F "prompt=A serene sunset over mountains, seamless 360 panorama" \
  https://ps.codejar.net/api/hdri-generator/generate
```

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

## Use Cases

- **Three.js 360° Panoramas**: Seamless environment maps for WebGL/Three.js scenes
- **VR/AR Environments**: 360-degree backgrounds for virtual reality applications
- **Game Environments**: Background HDRIs for realistic lighting in 3D games
- **Product Visualization**: Environment lighting for product renders