# Texture Generator

Generate seamless, tilable 2D textures for 3D asset mapping.

## Description

Generate high-resolution, seamless textures suitable for UV mapping on 3D models. The generated textures tile flawlessly in all directions with no visible seams.

## Authentication

**Required**: x402 payment

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

## Request

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

**Content-Type**: `application/json`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| textureDescription | string | Yes | Description of the texture (e.g., "weathered red brick with mortar") |
| textureType | string | Yes | Material type hint (e.g., "brick", "wood", "metal", "fabric") |

## Response

**200 OK**

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

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the generated texture image |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | Missing or invalid textureDescription or textureType |
| 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 \
  -H "Content-Type: application/json" \
  -d '{"textureDescription":"weathered red brick with moss","textureType":"brick"}' \
  https://ps.codejar.net/api/texture-generator/generate
```

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

## Use Cases

- **3D Game Development**: Tileable textures for environments, characters, and props
- **Architectural Visualization**: Realistic material textures for renders
- **Product Design**: Surface materials for 3D product mockups
- **VR/AR Applications**: Seamless textures for virtual environments
