videogen/docs/freegen-desktop.md
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

5.6 KiB

freegen desktop integration

This document describes how the Menivor desktop app can use tools/freegen/server.py as a local generation engine. Local generation is free for users — it uses FLUX.1-schnell (Apache-2.0), Kokoro-82M TTS (Apache-2.0), and ffmpeg, all running on the user's Mac.


Architecture

Menivor desktop app  ←→  freegen/server.py (FastAPI, 127.0.0.1:8765)
                             ├── stills.py   (FLUX.1-schnell 4-bit via mflux)
                             ├── assemble.py (Kokoro TTS + ffmpeg)
                             └── /results/*  (serve finished files locally)

The sidecar speaks the same wire protocol as api.menivor.com/api/v1, so the desktop app only needs one setting changed: the API base URL.


Sidecar endpoints

All paths are under http://127.0.0.1:8765/api/v1.

GET /me

Connection check. Returns {"data": {"id": "local", ...}}.

GET /pilot/capabilities

Returns {"data": {"mode": "local", "generation": {"reels": true, "broll": true}, "freegen": true}}.

POST /jobs

Create a generation job. Body:

{
  "kind": "image_from_prompt",
  "params": {
    "prompt": "...",
    "seed": 42,
    "steps": 4,
    "lora_path": "/optional/lora.safetensors",
    "saved_model": "/optional/mflux-schnell-q4"
  }
}

Supported kind values:

kind params output
image_from_prompt prompt, seed, steps, lora_path, saved_model PNG
assemble shots (array), voice_blend, speed, music, product_name, product_url MP4
voiceover text, blend, speed WAV

Returns {"data": {"job_id": "...", "state": 0, ...}} immediately.

GET /jobs/{job_id}

Poll the job. state: 0=pending, 1=complete, -1=failed.

When state == 1, result_url is a local file URL: http://127.0.0.1:8765/results/<job_id>.png (or .mp4, .wav).

GET /results/{filename}

Serve a finished result file. The desktop app streams this to save to disk.


Desktop app changes needed

The Menivor desktop app (Rust GPUI, apps/desktop/) needs two additions:

1. "Local (free)" engine toggle in Settings

In src/config/preferences.rs, Preferences already has api_base_url. Add a boolean use_local_engine and a helper to flip it:

// Preferences struct
pub use_local_engine: bool,

// In Preferences::normalized_api_base():
if self.use_local_engine {
    return "http://127.0.0.1:8765/api/v1".to_owned();
}

In the Settings UI (src/ui/), add a toggle row:

[ ] Use local free engine  (freegen — runs on this Mac, no API key needed)
    API base: http://127.0.0.1:8765/api/v1

When toggled on, write use_local_engine=true to the preferences file and set api_base_url=http://127.0.0.1:8765/api/v1.

2. Launching the sidecar

When the user enables the local engine, the desktop app should launch the sidecar as a child process and monitor it.

Add a LocalSidecar struct in src/domain/ or a new src/sidecar/ module:

pub struct LocalSidecar {
    child: Option<std::process::Child>,
    port: u16,
}

impl LocalSidecar {
    /// Start server.py in the freegen venv.
    pub fn start(freegen_dir: &Path) -> std::io::Result<Self> {
        let python = freegen_dir.join(".venv/bin/python");
        let server = freegen_dir.join("server.py");
        let child = std::process::Command::new(python)
            .arg(server)
            .spawn()?;
        Ok(Self { child: Some(child), port: 8765 })
    }

    /// Check liveness with GET /health.
    pub fn is_running(&self) -> bool {
        // ureq GET http://127.0.0.1:8765/health -> 200
        todo!()
    }

    pub fn stop(&mut self) {
        if let Some(mut child) = self.child.take() {
            let _ = child.kill();
        }
    }
}

The desktop app should:

  1. Start the sidecar on first toggle, or auto-start if use_local_engine is true.
  2. Show a spinner while the sidecar starts (typically < 5 s with the model cached).
  3. Stop the sidecar when the app quits.

Disk check before enabling

The freegen README lists disk requirements. The desktop app should warn the user before downloading the FLUX model:

  • Model not cached: "First use requires ~34 GB of free disk. Continue?"
  • Model cached (checkpoint only): "Requires ~9 GB of free disk."

Check by calling GET /api/v1/pilot/capabilities — if it returns "freegen": true the sidecar is already running with the model ready.


Rust changes scope

The Rust changes above are minimal (two files, ~50 lines net). They are described as a design note here because the full build requires Xcode + Cargo and the current disk is under 6 GB free after the model download. Implement them once the FLUX model is saved and the HF cache is cleared.


User-facing copy (Settings page)

Local (free) engine

  Make AI videos on this Mac with open models.  No API key.  No cloud bill.
  Generation is always free.  Upgrade for cloud speed, auto-posting, and teams.

  [ Enable local engine ]

  Requirements: macOS (Apple Silicon), ~9 GB disk (one-time setup).
  First use downloads FLUX.1-schnell (~34 GB).  After setup only ~9 GB is used.

Testing the sidecar without the desktop app

cd videogen/tools/freegen
source .venv/bin/activate
python server.py &

# create a job
curl -s -X POST http://127.0.0.1:8765/api/v1/jobs \
  -H 'Content-Type: application/json' \
  -d '{"kind":"voiceover","params":{"text":"Hello from freegen.","blend":"af_heart:1.0"}}' | jq .

# poll
JOB_ID=<id from above>
curl -s http://127.0.0.1:8765/api/v1/jobs/$JOB_ID | jq .

# when state==1, download result
curl -O http://127.0.0.1:8765/results/$JOB_ID.wav