An AI-powered media generation platform built with FastAPI and SQLite. Generate images from text prompts and convert them to animated videos.
- Text-to-Image Generation: Create AI images from text prompts with customizable aspect ratios
- Image-to-Video Conversion: Convert generated images into animated videos with one click
- Task Queue: Configurable concurrent task management with real-time WebSocket updates
- Image Management: Grid display, pagination, fullscreen preview, and deletion
- Video Playback: Inline video player with controls
- Multi-Config Support: Switch between multiple API configurations
- Persistent Storage: SQLite database for history and prompt retrieval
Create virtual environment:
python -m venv venvActivate virtual environment:
Windows:
venv\Scripts\activateLinux/macOS:
source venv/bin/activateInstall packages:
pip install -r requirements.txtCopy the example config file:
# Windows
copy data\configs.example.json data\configs.json
# Linux/macOS
cp data/configs.example.json data/configs.jsonEdit data/configs.json with your API credentials:
{
"max_concurrent": 2,
"api_configs": [
{
"name": "grok",
"base_url": "https://your-api-endpoint.com",
"api_key": "your-api-key",
"model": "grok-imagine-1.0",
"proxy": ""
},
{
"name": "grok-video",
"base_url": "https://your-api-endpoint.com",
"api_key": "your-api-key",
"model": "grok-imagine-1.0-video",
"proxy": ""
}
]
}python app.pyOr use uvicorn with hot reload:
uvicorn app:app --reload --port 8989Open your browser and visit: http://localhost:8989
- Enter a text prompt describing the image you want
- Select an aspect ratio (Default, 9:16, 16:9, 4:3, 1:1)
- Choose the number of images (1-10)
- Click Generate
- Hover over any generated image
- Click the 🎬 button
- Configure video settings:
- Aspect Ratio: 16:9, 9:16, or 1:1
- Duration: 5 or 10 seconds
- Motion Description: Optional text to guide the animation
- Click Generate Video
- Click any image for fullscreen preview with navigation
- Click ℹ️ to view the original prompt
- Click 🗑️ to delete an image or video
- Videos display with a VIDEO badge and inline player controls
aig_pic/
├── app.py # FastAPI main application
├── requirements.txt # Python dependencies
├── data/
│ ├── app.db # SQLite database (auto-generated)
│ ├── configs.json # API configuration (create from example)
│ └── configs.example.json # Example configuration
├── src/
│ ├── client.py # External API client (image & video)
│ ├── config.py # Configuration management
│ ├── db.py # Database operations
│ └── tasks.py # Task queue with WebSocket broadcast
├── static/
│ ├── index.html # Frontend page
│ ├── app.js # Frontend logic
│ └── styles.css # Styles
├── output/ # Generated media storage
└── doc/
└── homepage.png # Screenshot
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Main page |
| GET | /api/configs |
List available configurations |
| POST | /api/tasks |
Create image/video generation task |
| GET | /api/tasks |
List all tasks |
| GET | /api/tasks/{id} |
Get task status |
| GET | /api/images |
List images (paginated) |
| GET | /api/images/{id}/prompt |
Get image prompt |
| POST | /api/images/{id}/to-video |
Convert image to video |
| DELETE | /api/images/{id} |
Delete image |
| WS | /ws/tasks |
Real-time task updates |
- Backend: FastAPI + Uvicorn
- Database: SQLite
- HTTP Client: httpx (async)
- Frontend: Vanilla HTML/CSS/JavaScript
- Real-time: WebSocket
MIT
