# Jimeng AI Tool

AI generation tool supporting text-to-image (Seendance 2.0) and image-to-video (Seedream Lite 5.0).

## Features

- **Text-to-Image**: Generate images from text prompts using Seendance 2.0
- **Image-to-Video**: Convert images to videos using Seedream Lite 5.0
- **Task Management**: Async task submission and status tracking
- **Caching**: Built-in task result caching (24h TTL)

## API Endpoints

- `GET /health` - Health check
- `POST /generate` - Submit generation task
- `GET /status/{task_id}` - Query task status
- `POST /cleanup` - Clean expired cache

## Environment Variables

```bash
JIMENG_API_KEY=your_api_key
JIMENG_COOKIE=your_cookie
JIMENG_BASE_URL=https://api.jimeng.ai
```

## Usage

### Start Service

```bash
uv run python main.py --port 8000
```

### Text-to-Image Example

```bash
curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d '{
    "action": "text2image",
    "prompt": "A cute cat in garden",
    "aspect_ratio": "1:1",
    "image_count": 1
  }'
```

### Image-to-Video Example

```bash
curl -X POST http://localhost:8000/generate \
  -H "Content-Type: application/json" \
  -d '{
    "action": "image2video",
    "image_url": "https://example.com/image.jpg",
    "prompt": "Make it move",
    "video_duration": 5
  }'
```

## Testing

```bash
uv run python tests/test_jimeng.py
```

## Registration

Tool registered as `jimeng_ai` in the tool registry with runtime type `local`.
