# Product Staging

Place products in realistic e-commerce settings.

## Description

Upload a product image and optionally a reference background scene or scene description. The API will generate a professional product image with the product naturally integrated into the specified setting with proper lighting, shadows, and scale.

## Authentication

**Required**: x402 payment

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

## Request

**Endpoint**: `POST /api/product-staging/generate`

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

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| product | file | Yes | Product image, transparent background preferred (JPG, PNG, or WebP, max 10MB) |
| background | file | No | Reference background/scene image (JPG, PNG, or WebP, max 10MB) |
| sceneDescription | string | No | Description of desired scene, e.g. "luxury boutique", "minimalist white", "outdoor garden" |

## 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 "product=@sneaker.png" \
  -F "background=@boutique.jpg" \
  -F "sceneDescription=luxury boutique" \
  https://ps.codejar.net/api/product-staging/generate
```

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