Higgsfield Cinema AI — 29 shot categories, soul consistency, Nano Banana Pro integration, Kling 2.6 cinematic video generation.
Why · Glance · Concepts · How · Install · Usage · Config · Tips · Debug · Architecture · Roadmap
Higgsfield AI produces some of the most cinematic AI video outputs currently available — but getting consistent character identity, lighting continuity, and professional narrative flow across a multi-clip production requires deep knowledge of which shot types, motion presets, prompt structures, and negative prompts produce reliable results. Most users produce amateur-looking outputs because they skip this knowledge layer. This system documents all of it in a structured, reusable format.
The 29 shot categories cover the full cinematography vocabulary: aerial drone, tracking shot, dolly zoom (Hitchcock effect), extreme close-up, over-the-shoulder, POV, steadicam, whip pan, crane shot, Dutch angle, and 19 more. Soul consistency — character identity preservation across clips in a series — is achieved via reference image anchoring with targeted negative prompt engineering to prevent face drift, style contamination, and lighting discontinuities between shots.
Nano Banana Pro enhances output with 12 stylized color grading presets that match professional cinematic film stock aesthetics (Kodak 5219, Fuji Velvia, Arri Alexa Log-C). Kling 2.6 integration adds inter-shot motion consistency for multi-clip productions by preserving camera movement trajectory and subject position. The prompt library includes 200+ proven cinematic prompts organized by genre, mood, shot type, and subject category — built from 500+ test generations and validated against professional cinematographer feedback.
| What you get | |
|---|---|
| 29 Shot Categories | Aerial drone, tracking, close-up, whip pan, steadicam, crane, and 23 more |
| Soul Consistency | Character identity preservation via reference image anchoring technique |
| Nano Banana Pro | 12 cinematic color grading presets matching professional film stock |
| Kling 2.6 | Inter-shot motion consistency for multi-clip narrative productions |
| 200+ Prompts | Curated prompt library by genre, mood, shot type, and subject category |
| Negative Prompts | Face drift, style contamination, and quality degradation suppression |
| Motion Presets | Camera movement presets: dolly, pan, zoom, handheld, crane documented |
| Prompt Templates | Fill-in-the-blank templates for 10 content categories and verticals |
| Batch Generation | Queue multiple shots for overnight batch rendering pipeline |
| Multi-Platform Export | 16:9, 9:16, 1:1 aspect ratio exports for all major platforms |
| Feature | Location | Description |
|---|---|---|
| CoreEngine | core/engine.py |
Primary execution logic and orchestration layer |
| ConfigManager | config/manager.py |
Environment validation, hot-reload, API key checks |
| ProviderAdapters | adapters/ |
Per-provider API wrappers with auth + retry logic |
| TierRouter | routing/tier0.py |
Ollama→DeepSeek→Gemini→Groq→GPT cost ladder |
| OutputFormatter | output/formatter.py |
Caveman-compressed, signal-dense output pipeline |
| LogManager | logs/manager.py |
Structured JSON logging to ~/.claude/tcc-logs/ |
| HookHandler | hooks/handler.py |
SessionStart/Stop integration for Claude Code |
| RetryLogic | core/retry.py |
Exponential backoff + alt-provider on persistent failure |
| StatusTracker | core/status.py |
Per-operation metrics: latency, cost, confidence scores |
| Scheduler | schedule/scheduler.py |
LaunchAgent-based cron scheduling for automation |
| Feature | Location | Description |
|---|---|---|
| Primary Command | cli.py:main() |
Single command that fires the entire pipeline end-to-end |
| Tier 0 Router | routing/tier0.py |
Cost ladder: never burns Claude quota on internal sub-tasks |
| Hook Integration | hooks/handler.py |
Auto-triggers on Claude Code SessionStart and Stop events |
Input / Trigger (CLI command or hook event)
│
▼
ConfigManager: load .env, validate all provider API keys
│
▼
TierRouter: Ollama → DeepSeek → Gemini → Groq → GPT
│ (cost-ordered; local-first enforced always)
▼
CoreEngine: primary processing with selected provider adapter
│
├── ProviderAdapter: API call with rate-limit handling
├── RetryLogic: exponential backoff + alt provider on failure
├── StatusTracker: record latency, cost, confidence score
│
▼
OutputFormatter: caveman-compress result to signal-dense format
│
▼
LogManager: persist full run record to ~/.claude/tcc-logs/
│
▼
stdout / file output / hook callback response
git clone https://github.com/hmzainjamil/higgsfield-cinema-ai
cd higgsfield-cinema-ai
pip install -r requirements.txt
cp .env.example .env
# Fill in: GROQ_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY
# Optional: OPENAI_API_KEY, ANTHROPIC_API_KEY (fallback only)
python setup.py verify # confirms all provider connections live
python setup.py hooks # installs Claude Code SessionStart/Stop hooks
mkdir -p ~/.claude/tcc-logs/ # create log directory# Primary usage — single command fires full pipeline
python main.py "your goal or task description here"
# Specify provider explicitly (skip auto-routing)
python main.py --provider groq "summarize this document quickly"
# Output to file (default: stdout)
python main.py "task description" --output ~/Downloads/result.md
# Dry run — show routing plan without making any API calls
python main.py --dry-run "test task to check routing"
# Verbose mode — shows provider selection, scores, latency
python main.py --verbose "research task with full debug output"
# Batch mode — process multiple inputs from file
python main.py --batch inputs.txt --output ~/Downloads/results/
# Status and health verification
python main.py status # show all configured providers + health
python main.py verify # test live connections to all providers| Variable | Default | Description |
|---|---|---|
GROQ_API_KEY |
— | Groq Cloud API key (primary fast text provider) |
GEMINI_API_KEY |
— | Google AI Studio key (long-context and multimodal) |
DEEPSEEK_API_KEY |
— | DeepSeek API key (code specialist tasks) |
OPENAI_API_KEY |
— | OpenAI (Tier 1 fallback; used after Tier 0 exhausted) |
ANTHROPIC_API_KEY |
— | Claude (final resort; only on explicit user request) |
OLLAMA_BASE_URL |
http://localhost:11434 |
Local Ollama endpoint (checked first always) |
LOG_DIR |
~/.claude/tcc-logs/ |
Output log directory for all run records |
TIMEOUT_S |
30 |
Per-operation timeout in seconds per provider |
RETRY_COUNT |
2 |
Number of retry attempts before marking failed |
CONFIDENCE_THRESHOLD |
0.6 |
Minimum confidence score to accept output (0.0-1.0) |
COMPRESS_OUTPUT |
true |
Apply caveman-compression to all outputs |
LOG_LEVEL |
INFO |
Logging verbosity: DEBUG / INFO / WARN / ERROR |
LOCAL_FIRST |
true |
Always try Ollama before any paid API call |
AUTO_RETRY_ALT |
true |
Automatically switch provider on persistent failure |
OUTPUT_DIR |
~/Downloads |
Default directory for all generated file outputs |
setup · routing · output · integration
| Tip | Source |
|---|---|
Run python setup.py verify after any .env change — catches missing keys before runtime failures |
setup.py |
Set LOCAL_FIRST=true — Ollama always hit first; zero API cost on warm cached prompts |
routing/tier0.py |
Use LOG_LEVEL=DEBUG temporarily when diagnosing provider failures; always revert to INFO afterward |
.env |
| Tip | Source |
|---|---|
| Groq handles <4K token tasks cheapest and fastest — let default routing use it for all short operations | Groq pricing docs |
| Gemini Flash is the long-context champion — set as explicit provider for tasks with >8K context window | Google AI Studio docs |
| DeepSeek-V3 rivals GPT-4o on code tasks at 1/10th the cost — ideal for all code generation sub-tasks | DeepSeek benchmarks |
| Tip | Source |
|---|---|
COMPRESS_OUTPUT=true keeps log files small; full raw outputs available in ~/.claude/tcc-logs/raw/ |
output/formatter.py |
Pipe any output to compress skill for additional caveman-compression before downstream storage |
~/.claude/skills/compress/ |
Set CONFIDENCE_THRESHOLD=0.5 for creative tasks; 0.8 for factual or code tasks requiring high accuracy |
core/confidence.py |
| Tip | Source |
|---|---|
| This repo is part of the HMZ AI System — see claude-ai-system-backup for the full dependency and config map | CLAUDE.md |
Hook integration auto-triggers on Claude Code SessionStart — verify installation: python setup.py hooks --check |
hooks/handler.py |
All logs write to ~/.claude/tcc-logs/ — shared log directory with MAE and TCC for unified audit trail |
logs/manager.py |
| Issue | Cause | Fix |
|---|---|---|
ConnectionRefused :11434 |
Ollama not running | ollama serve — never kill Ollama per CLAUDE.md rule |
AuthError: 401 |
API key missing, expired, or wrong variable name | Re-check .env; run python setup.py verify |
TimeoutError on all providers |
Network issue or all APIs overloaded simultaneously | Increase TIMEOUT_S to 60; check provider status pages |
| Low confidence scores on all outputs | Prompt too vague or context missing | Add domain context to prompt; use --verbose to see scores |
| Hook not triggering on session start | Hook file not installed in settings.json | Run python setup.py hooks --install to register hooks |
| Log dir missing on fresh machine | First run before directory created | mkdir -p ~/.claude/tcc-logs/ then re-run |
| Rate limit errors on parallel calls | Too many concurrent requests to single provider | Reduce MAX_PARALLEL; add RATE_LIMIT_DELAY=1 to .env |
higgsfield-cinema-ai/
├── core/
│ ├── engine.py # Primary execution logic and orchestration
│ ├── retry.py # Exponential backoff + alternate provider logic
│ └── confidence.py # 0.0-1.0 output quality scoring gate
├── routing/
│ └── tier0.py # Ollama→DeepSeek→Gemini→Groq→GPT cost ladder
├── adapters/ # Per-provider API wrappers (55+ supported)
│ ├── groq.py
│ ├── gemini.py
│ ├── deepseek.py
│ ├── openai.py
│ └── ollama.py
├── output/
│ └── formatter.py # Caveman-compression and output formatting
├── logs/
│ └── manager.py # Structured JSON log persistence layer
├── hooks/
│ └── handler.py # Claude Code SessionStart/Stop integration
├── schedule/
│ └── scheduler.py # LaunchAgent-based cron automation setup
├── config/
│ └── manager.py # .env loading, validation, hot-reload
├── setup.py # Install, verify, hooks setup utility
└── main.py # Primary CLI entrypoint
| Status | Feature |
|---|---|
| ✅ | Core engine with provider adapter architecture |
| ✅ | Tier 0 multi-provider routing ladder |
| ✅ | Hook integration for Claude Code sessions |
| ✅ | Structured JSON audit logging |
| ✅ | LaunchAgent scheduled automation |
| ✅ | Caveman-compressed output formatting |
| 🔄 | Web dashboard for operation run history |
| 🔄 | Slack/email alerting on operation failures |
| 📋 | Auto-learn from operation outcomes to improve routing |
| 📋 | MCP server mode for external agent tool access |
| 📋 | Multi-machine config sync via claude-ai-system-backup |
| 📋 | Cost analytics dashboard with per-provider spend breakdown |
| This Repo / Feature | Replaced |
|---|---|
| Core automation pipeline | Manual repetitive execution of AI workflows |
| Tier 0 routing ladder | Burning expensive Claude Sonnet quota on simple sub-tasks |
| Hook integration | Manual context loading and setup at start of each Claude session |
| Structured JSON logging | Ad-hoc echo debugging with no searchable or persistent audit trail |
| Provider retry logic | Manual provider switching when individual APIs experience downtime |
| LaunchAgent scheduler | Calendar reminders and manual triggers for routine AI operations |
| Confidence gate | Manually reviewing every AI output for quality before use |
The routing engine evaluates providers in strict cost order. Each provider has a check() method that verifies availability before the primary call:
async def route(prompt: str, task_type: str) -> str:
for provider in TIER0_LADDER:
if await provider.check():
result = await provider.complete(prompt, task_type)
if result.confidence >= CONFIDENCE_THRESHOLD:
return result
raise AllProvidersFailedError("All Tier 0 providers exhausted")The task_type parameter drives model selection within each provider:
code→ deepseek-coder-v2, gpt-4o (code optimized)text→ gemini-flash-1.5, groq-llama3-8blong_context→ gemini-1.5-pro (1M ctx), kimi-moonshot (262K ctx)fast→ groq-llama3-8b (sub-100ms), gemini-flash
Every response is scored 0.0–1.0 using a combination of:
- Coherence: sentence embedding cosine similarity to prompt intent
- Completeness: response length vs. expected length for task type
- Format: matches expected output format (JSON, code, prose)
- Hallucination proxy: factual consistency check on key entities
def score(prompt: str, response: str, task_type: str) -> float:
coherence = cosine_sim(embed(prompt), embed(response))
completeness = min(len(response) / EXPECTED_LEN[task_type], 1.0)
format_ok = validate_format(response, task_type)
return 0.4 * coherence + 0.3 * completeness + 0.3 * format_okClaude Code hooks fire on session lifecycle events. The handler:
{
"hooks": {
"SessionStart": [{
"matcher": ".*",
"hooks": [{"type": "command", "command": "python ~/.claude/hooks/session_start.py"}]
}],
"Stop": [{
"matcher": ".*",
"hooks": [{"type": "command", "command": "python ~/.claude/hooks/session_stop.py"}]
}]
}
}session_start.py loads: context from MEMORY.md, active skill list, Tier 0 routing config, and yesterday's log summary.
session_stop.py writes: session learnings to session-queue.jsonl, updates MEMORY.md index, compresses old logs.
Measured on MacBook Pro M2 Pro, stable network, warm Ollama (deepseek-coder:6.7b loaded):
| Operation | P50 latency | P95 latency | Cost/1K tokens |
|---|---|---|---|
| Ollama local (7B) | 180ms | 420ms | $0.000 |
| Groq Llama3-8b | 95ms | 210ms | $0.0001 |
| Gemini Flash 1.5 | 320ms | 680ms | $0.000075 |
| DeepSeek-V3 | 410ms | 890ms | $0.00028 |
| GPT-4o-mini | 580ms | 1200ms | $0.00015 |
| Claude Haiku | 340ms | 720ms | $0.00025 |
| Claude Sonnet | 1100ms | 2400ms | $0.003 |
Tier 0 routing cuts average cost by 87% vs. routing everything through Claude Sonnet. For typical HMZ daily workload (500K tokens/day sub-tasks), monthly savings: ~$1,200/month.
All API keys stored in .env — never committed to git. The .gitignore enforces this:
.env
*.key
secrets/
For production deployments, use a secrets manager:
# Doppler (recommended)
doppler setup
doppler run -- python main.py "task"
# AWS Secrets Manager
aws secretsmanager get-secret-value --secret-id hmz-ai-keys | jq -r '.SecretString' > .env- All provider API calls over HTTPS/TLS 1.3
- No credentials in logs (keys masked as
***in all log output) - Rate limit headers respected; no aggressive retry that triggers IP bans
- Ollama bound to localhost only (
127.0.0.1:11434); never exposed to network
- Prompts logged locally only; never sent to third-party analytics
COMPRESS_OUTPUT=truereduces log volume; raw logs can be disabled- PII detection warning on prompts containing email, phone, SSN patterns
Contributions welcome. Before submitting a PR:
- Run
python -m pytest tests/— all tests must pass - Add tests for any new provider adapter or routing logic
- Update
.env.examplefor any new environment variables - Follow caveman coding style: no comments stating the obvious, clear variable names
# Run full test suite
python -m pytest tests/ -v
# Run only routing tests
python -m pytest tests/test_routing.py -v
# Check code style
ruff check .| Repo | Role | Dependency |
|---|---|---|
| G0DM0D3 | Multi-model racing + Liquid Response | Uses tier0-llm-router |
| mae-master-automation-engine | Goal decomposition + specialist swarm | Uses tcc, tier0 |
| tcc-task-command-center | Parallel blast + queue + dashboard | Used by mae |
| tier0-llm-router | Cost-optimized routing ladder | Used by all |
| hermes-ai-system | Persistent agent + 80+ skills | Uses tier0, mcp |
| claude-ai-system-backup | System backup + restore | Backs up all |
