Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Content Generator

A multi-provider AI content generation framework for music, video, and images.

Python 3.12+ License: MIT

✨ Features

  • Multi-Provider Architecture: Google (Lyria, Veo, Imagen), AIMLAPI (MiniMax), KlingAI
  • Plugin System: Add new providers without modifying core code
  • Style Presets: Pre-configured prompts for jazz, blues, cinematic, and more
  • Job Tracking: SQLite-based persistence with duplicate detection and cost management
  • Async-First: Non-blocking operations with proper async/await
  • Type-Safe: Full type hints with Pydantic configuration
  • CLI Interface: Easy-to-use command-line tool

πŸš€ Quick Start

Installation

# Clone and install
git clone <repository>
cd ai-content
uv sync

# Or install as package
pip install -e .

Configuration

Create .env file:

# Google APIs (Lyria, Veo, Imagen)
GEMINI_API_KEY=your_google_api_key

# AIMLAPI (MiniMax)
AIMLAPI_KEY=your_aimlapi_key

# KlingAI Direct
KLINGAI_API_KEY=your_kling_api_key
KLINGAI_SECRET_KEY=your_kling_secret

Basic Usage

# Generate music with preset
uv run ai-content music --style jazz --provider lyria

# Generate music with custom prompt
uv run ai-content music \
  --prompt "Smooth jazz fusion with walking bass" \
  --provider lyria \
  --bpm 95

# Generate video
uv run ai-content video \
  --prompt "Dragon soaring over mountains" \
  --provider veo \
  --aspect 16:9

# List available options
uv run ai-content list-providers
uv run ai-content list-presets

πŸ“¦ Package Structure

ai-content/
β”œβ”€β”€ src/ai_content/          # Main package
β”‚   β”œβ”€β”€ core/                # Protocols, Registry, Result
β”‚   β”œβ”€β”€ config/              # Pydantic settings
β”‚   β”œβ”€β”€ providers/           # Provider implementations
β”‚   β”‚   β”œβ”€β”€ google/          # Lyria, Veo, Imagen
β”‚   β”‚   β”œβ”€β”€ aimlapi/         # MiniMax
β”‚   β”‚   └── kling/           # KlingAI Direct
β”‚   β”œβ”€β”€ pipelines/           # Orchestration workflows
β”‚   β”œβ”€β”€ integrations/        # External services
β”‚   β”œβ”€β”€ presets/             # Style presets
β”‚   β”œβ”€β”€ utils/               # Utilities
β”‚   └── cli/                 # Typer CLI
β”œβ”€β”€ configs/                 # YAML configuration
β”œβ”€β”€ docs/                    # Documentation
β”œβ”€β”€ examples/                # Example scripts (8)
└── .agent/                  # AI agent configuration

🎬 Full Content Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FULL CONTENT PIPELINE                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1️⃣ SOURCE SELECTION
   Archive.org β†’ search_items("1930s jazz")
        β”‚
        β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Source metadata β”‚
   β”‚ β€’ identifier    β”‚
   β”‚ β€’ thumbnail_url β”‚
   β”‚ β€’ audio_url     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
2️⃣ CONTENT GENERATION (PARALLEL)
            β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                 β”‚
   β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🎡 Music β”‚   β”‚ πŸ–ΌοΈ Image β”‚
β”‚  Lyria   β”‚   β”‚  Imagen  β”‚
β”‚  MiniMax β”‚   β”‚          β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
     β”‚              β”‚
     β”‚              β–Ό
     β”‚        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚        β”‚ 🎬 Video β”‚
     β”‚        β”‚   Veo    β”‚
     β”‚        β”‚   Kling  β”‚
     β”‚        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
     β”‚             β”‚
3️⃣ POST-PROCESSING
     β”‚             β”‚
     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
            β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Media Merge    β”‚
   β”‚  (FFmpeg)       β”‚
   β”‚  audio + video  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
4️⃣ OUTPUT DESTINATION
            β”‚
            β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Local Export   β”‚ ← Always save locally first
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                 β”‚
   β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ YouTube  β”‚   β”‚    S3    β”‚
β”‚ Upload   β”‚   β”‚  Upload  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“„ Examples

Example Description
01_basic_music.py Simplest music generation
02_basic_video.py Simplest video generation
03_lyrics_workflow.py Lyrics-first with structure tags
04_image_to_video.py Animate a static image
05_provider_comparison.py Compare multiple providers
06_music_video_pipeline.py Full end-to-end pipeline
07_archive_integration.py Search Archive.org for sources
08_custom_provider.py Create your own provider
# Run examples
python examples/01_basic_music.py jazz
python examples/06_music_video_pipeline.py cinematic space

πŸ“Š Job Tracking & Cost Management

The framework includes a robust job tracking system to manage long-running AI generation requests, prevent duplicate API calls, and monitor costs.

Key Features

  • Persistent SQLite Storage: Jobs saved to ~/.ai-content/jobs.db
  • Duplicate Detection: MD5 hash-based detection prevents redundant API calls
  • Status Lifecycle: queued β†’ processing β†’ completed β†’ downloaded (or failed)
  • Cost Awareness: Track API usage to manage expenses

Workflow for Long-Running Jobs

Some providers (like MiniMax) can take 5-15 minutes to complete. Use this workflow:

# 1. Submit generation (returns immediately with job ID)
uv run ai-content music \
  --prompt "Smooth bachata fusion" \
  --provider minimax \
  --lyrics data/lyrics.txt

# If it times out, note the generation_id printed

# 2. Check status later
uv run ai-content music-status <generation_id>

# 3. Download when complete
uv run ai-content music-status <generation_id> \
  --output output/music/my_track.mp3

Managing Jobs

# List all jobs
uv run ai-content jobs

# Filter by status
uv run ai-content jobs --status queued
uv run ai-content jobs --status completed

# Filter by provider
uv run ai-content jobs --provider minimax

# View statistics
uv run ai-content jobs-stats

# Sync pending jobs (check API status)
uv run ai-content jobs-sync

# Sync and auto-download completed
uv run ai-content jobs-sync --download

Duplicate Prevention

Running the same prompt twice will detect the duplicate:

# First run - generates normally
uv run ai-content music --prompt "Jazz fusion" --provider minimax

# Second run - detects duplicate
uv run ai-content music --prompt "Jazz fusion" --provider minimax
# ⚠️ Duplicate found (already completed)
#    Job ID: abc123...
#    Output: output/music/...
#    Use --force to generate anyway

# Force regeneration if needed
uv run ai-content music --prompt "Jazz fusion" --provider minimax --force

Manually Registering Past Jobs

If you ran a generation before job tracking was enabled:

from ai_content.core.job_tracker import get_tracker

tracker = get_tracker()
tracker.create_job(
    generation_id="your-generation-id",
    provider="minimax",
    content_type="music",
    prompt="Your original prompt",
    command="ai-content music --prompt ...",
)

Then sync to get current status:

uv run ai-content jobs-sync --download

🎡 Music Providers

Provider Vocals Real-time Reference Audio Best For
Lyria ❌ βœ… ❌ Fast instrumentals
MiniMax βœ… ❌ βœ… Vocals, style transfer
from ai_content import ProviderRegistry
from ai_content.presets import get_music_preset

# Get preset and provider
preset = get_music_preset("jazz")
provider = ProviderRegistry.get_music("lyria")

# Generate
result = await provider.generate(
    prompt=preset.prompt,
    bpm=preset.bpm,
    duration_seconds=30,
)

if result.success:
    print(f"Saved: {result.file_path}")

🎬 Video Providers

Provider Speed Quality Image-to-Video Best For
Veo Fast (~30s) Good βœ… Quick iterations
Kling Slow (5-14min) Highest βœ… Final renders
from ai_content import ProviderRegistry
from ai_content.presets import get_video_preset

# Get preset and provider
preset = get_video_preset("space")
provider = ProviderRegistry.get_video("veo")

# Generate
result = await provider.generate(
    prompt=preset.prompt,
    aspect_ratio=preset.aspect_ratio,
)

🎨 Available Presets

Music Presets

  • jazz - Smooth jazz fusion (95 BPM)
  • blues - Delta blues (72 BPM)
  • ethiopian-jazz - Ethio-jazz fusion (85 BPM)
  • cinematic - Epic orchestral (100 BPM)
  • electronic - Progressive house (128 BPM)
  • ambient - Atmospheric pads (60 BPM)
  • lofi - Lo-fi hip-hop (85 BPM)
  • rnb - Contemporary R&B (90 BPM)

Video Presets

  • nature - Wildlife documentary
  • urban - Cyberpunk cityscape
  • space - Astronaut/sci-fi
  • abstract - Liquid metal/geometric
  • ocean - Underwater scenes
  • fantasy - Dragons/epic fantasy
  • portrait - Fashion/beauty

πŸ”§ Makefile Commands

# Setup
make install              # Install dependencies

# Music Generation
make test-jazz            # Jazz preset with Lyria
make test-blues           # Blues preset
make test-ethiopian-jazz  # Ethio-Jazz preset

# Test Pipeline
make test-performance-first  # Performance-First workflow
make test-lyrics-first       # Lyrics-First workflow
make test-provider-compare   # Compare Lyria vs MiniMax

# Multi-Provider
make run-multi-music         # MiniMax Music 2.0
make run-multi-video-kling   # KlingAI v2.1

# Help
make help                 # Show all commands

πŸ€– AI Agent Integration

This package includes AI agent configuration for development:

  • Rules: .agent/rules/RULES.md - Development standards
  • Skills: .agent/skills/*/SKILL.md - Domain knowledge
  • Workflows: .agent/workflows/*.md - Step-by-step guides

πŸ“š Documentation

πŸ”Œ Adding a New Provider

from ai_content.core.registry import ProviderRegistry
from ai_content.core.result import GenerationResult

@ProviderRegistry.register_music("my_provider")
class MyMusicProvider:
    name = "my_provider"
    supports_vocals = True
    supports_realtime = False
    supports_reference_audio = False
    
    async def generate(
        self,
        prompt: str,
        **kwargs,
    ) -> GenerationResult:
        # Your implementation
        ...

See Extending Guide for details.

πŸ“„ License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages