This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
AI Video Generator - Creates promotional videos using OpenRouter (storyboard generation) and Kie.ai Sora 2 (video generation). Videos are output to the output/ directory.
- Python 3.10+
- FFmpeg (for video merging only)
- API keys: OpenRouter + Kie.ai
pip install -r requirements.txt # Install dependencies
cp .env.example .env # Setup environment (edit with your keys)
streamlit run app.py # Launch web UI (http://localhost:8501)
python video_generator.py # Full workflow: storyboard + video generation
python genera_da_storyboard.py # Generate videos from existing storyboard JSON
python genera_video_presentazione.py # Generate presenter/avatar videos
python genera_loop_video.py # Generate single 15s loop video
python download_videos.py # Download videos from URLs (edit VIDEOS dict)
python merge_videos.py # Merge clips with FFmpegScripts overview:
| Script | Purpose | Notes |
|---|---|---|
app.py |
Web UI - Streamlit interface | Creates task, shows link to Kie.ai dashboard |
video_generator.py |
Full storyboard-to-video pipeline | Polling (may timeout) |
genera_da_storyboard.py |
Generate videos from saved storyboard | Polling |
genera_loop_video.py |
Single video with auto-download | Polling |
genera_video_presentazione.py |
Avatar/presenter videos | Callback |
download_videos.py |
Manual download from URLs | N/A |
merge_videos.py |
Merge clips via FFmpeg | N/A |
Web UI (app.py) workflow:
- User enters prompt, selects duration and aspect ratio
- App creates task via Kie.ai API
- App shows task ID and link to Kie.ai dashboard
- User checks video status on https://kie.ai/it/logs
CLI workflow (video_generator.py):
generate_storyboard()- Calls OpenRouter to create scene promptscreate_video_task()/wait_for_video()- Sends prompts to Kie.ai, polls for completiondownload_video()- Downloads completed videos tooutput/create_ffmpeg_concat_script()- Generates merge scripts
Kie.ai API:
- Base URL:
https://api.kie.ai/api/v1/jobs - Create task:
POST /createTaskreturnstaskId - Query status: Not reliably available - use dashboard or callback
- Dashboard (logs): https://kie.ai/it/logs
Kie.ai models: sora-2-text-to-video, sora-2-image-to-video, sora-2-pro-text-to-video, sora-2-pro-image-to-video, sora-watermark-remover
Required in .env:
OPENROUTER_API_KEY=sk-or-v1-xxx
KIE_API_KEY=your-kie-key
Optional:
SITE_URL=https://your-site.com
SITE_NAME=YourAppName
| Service | Cost |
|---|---|
| Sora 2 (10s/15s) | $0.15 (30 credits) |
| Sora 2 Pro | $0.75-$3.15 (varies) |
| OpenRouter (Claude Sonnet) | ~$0.01-0.05 per storyboard |
Credits: 1 credit = $0.005
See docs/kie_api_reference.md for full API documentation.
Key request parameters:
n_frames:"10"(10s) or"15"(15s) - must be string, not intaspect_ratio:"portrait"or"landscape"remove_watermark: booleanimage_urls: array of URLs (for image-to-video models)
Response codes: 200=success, 401=auth error, 402=insufficient credits, 429=rate limit
Generated files in output/:
scene_01.mp4,scene_02.mp4, ... - Individual video clipsstoryboard_YYYYMMDD_HHMMSS.json- Generated storyboardfilelist.txt- FFmpeg concat inputmerge_videos.bat/merge_videos.sh- Merge scripts