README.md
Phaino
Phaino is an open-source AI video and image studio that runs locally on your machine, with generations through Comfy Cloud (or your own Comfy API v2 endpoint). Pick a preset, add a prompt and a first frame, and every shot runs through a real ComfyUI workflow you can open, edit and fork locally. The studio listens on 127.0.0.1 only. Social publishing uses your own Zernio key. There is no hosted generation service or community publishing platform.
Quick start
Run these commands from the repository root. Requirements: Node.js >=24.22.1 <25, pnpm 12.11.2 (pinned in package.json), and ffmpeg plus ffprobe on PATH for media processing and exports.
| 1 | pnpm install |
| 2 | if (!(Test-Path -LiteralPath studio/.env.local)) { |
| 3 | Copy-Item -LiteralPath studio/.env.example -Destination studio/.env.local |
| 4 | } |
| 5 | pnpm dev:studio |
On macOS/Linux, replace the PowerShell copy step with test -f studio/.env.local || cp studio/.env.example studio/.env.local.
Open http://localhost:3000/settings and add your Comfy API key. One key serves Comfy Cloud and Comfy Router. You can also set COMFY_API_KEY in studio/.env.local and restart the server. Settings credentials take precedence over environment variables.
Setup with an AI agent
Give your agent this instruction:
Set up and start Phaino locally using the README. Request missing API keys through your private secret-input tool. Preserve existing configuration, check connectivity, and return the local app URL and any remaining setup issue.
Agents: follow these steps when asked to set up the app.
- Check prerequisites. Run
node --version,pnpm --version,ffmpeg -versionandffprobe -version. Match the Node and pnpm versions above. Report missing tools; media uploads, video preparation and exports need ffmpeg/ffprobe. Runpnpm installfrom the repository root. Bundled presets and model caches are already checked in; workflow export andmodels:syncare development steps. - Preserve configuration. Copy
studio/.env.exampleonly ifstudio/.env.localis absent. Keep existing values and local data. Check whetherCOMFY_API_KEYis nonempty without printing its value. Real generation needs demo mode off; setPHAINO_DEMO=offin the local env file if necessary. LeaveCOMFY_BASE_URLblank for Comfy Cloud. Use the custom backend instructions only when the user wants their own ComfyUI endpoint. - Start the studio. Run
pnpm dev:studioin a managed background terminal and wait for it to be ready. If it is already running from this checkout, reuse it. If port 3000 belongs to another app, runpnpm exec next dev -H 127.0.0.1 -p 3100fromstudio/and use that port for all URLs below. - Request missing keys privately. Check
GET /api/comfy/credentialson the local app; it returnsconfigured,source,maskedKeyandbaseUrl. Reuse existing credentials when configured. Otherwise request the user's Comfy key through the agent host's secret-input tool, with a link to the key page above. In T3 Code, userequest_secretwithdelivery: "file"for shell access. Read the delivered private file inside the shell process and write the key toCOMFY_API_KEYinstudio/.env.local, preserving other entries, then restart the studio. Keep key values out of chat, tool arguments, command-line arguments and logs. Never print credential files or commit them. If private input is unavailable, direct the user to enter the key in the app's Settings and continue after it is saved. - Check the connection. Request
GET /api/healthand inspect the JSONstatus; HTTP 200 alone does not prove the backend works.okmeans the Comfy endpoint is reachable. Fornot_configured, check credential presence and precedence. Forunauthorized, check the key and account's Cloud API access. Forunreachableorupstream_down, check the endpoint and report the service issue. Health probes Comfy Cloud or the custom endpoint, not Router or every model. Report any remaining limitation without claiming a successful generation. Generation spends credits; run a paid sample only when requested. - Finish with a useful handoff. Return the local app URL, connection status and any missing prerequisite or account access. If the user also wants an MCP client connected, use the MCP instructions below.
For Cloud workflow jobs, the account needs Cloud API access; a Router-only key can still be useful for partner models. Keys for individual model providers are not needed when using Comfy Router.
Optional social publishing: request a Zernio key as a separate secret only when the user asks to connect social accounts. Read it inside the shell process, build a JSON body with apiKey, and send it to PUT /api/social/credentials on the local app with Content-Type: application/json. This validates the key and saves it in <PHAINO_DATA_DIR>/social.json (default studio/.data/social.json). There is no ZERNIO_API_KEY env setting. Users can also enter it in Settings. Connecting an account does not authorize publishing a post.
What's in it
Explore: the home grid of all presets and categories.
Tools: Camera moves, Image and Video tool pages bound to presets, with a live job runner: uploads, progress over SSE, cancel, and recent runs.
Presets and models: open-weights presets in
presets/:Preset Tool Model bullet-time, crash-zoom, dolly-in, drone-pull-out, fpv-dive, orbit, whip-pan Camera LTX 2.5 ltx25-i2v Video LTX 2.5 wan22-i2v Video Wan 2.2 flux2-klein, flux2-klein-fast Image FLUX.2 Klein qwen-image Image Qwen Image kawarimi Kawarimi SCAIL-2 The Image and Video pickers list models, not presets, with search and family groups (FLUX, Qwen, Wan, LTX, ...). Each model's modes (text to video, image to video, first and last frame, text to image, edit) come from the registry in
studio/src/server/models/registry.ts, which covers every open-weights model Comfy ships an official template for: FLUX.1/2/3 (Dev, Krea, Kontext, Klein), Qwen Image (1, 2.1, 2511, 2512), Z-Image, HiDream (I1, O1, E1.1), SDXL, SD 3.5, Chroma, Anima, Mage-Flow, Ideogram 4, ERNIE, OmniGen2, Kandinsky 5, Wan 2.1/2.2 (+VACE, Alpha), LTXV/LTX 2/2.3, HunyuanVideo, MiniMax H3, FastH3, HuMo, Capybara and more. Template-backed modes are synced intomodels/cachebypnpm models:sync(see "Add a model" below); a mode that fails the gates stays hidden. Models that only edit or only take a first frame ask for that input and won't generate without it.Partner-model presets (Kling 3.0, Seedance 2.5, Nano Banana 2) run through Comfy Router with your Comfy key and use Comfy credits.
Kawarimi:
/kawarimiswaps the character in a video for one from an image. Inputs are a source video and a character image; the clip is trimmed to each engine's cap (5s for SCAIL-2) and the result keeps the source audio. Engines: SCAIL-2 (kawarimi, open, default) and partner engines through Router:kawarimi-genjutsu,kawarimi-seedance,kawarimi-h3,kawarimi-wan27,kawarimi-happyhorse,kawarimi-aleph. Kling O1 is hidden (the provider refused our own generated footage) and Kling 4.0 Video Edit is not on Router. Only swap in characters and footage you have the rights to. Over MCP, run thekawarimipreset with avideoand acharacterinput.Library: every generated output, downloadable or ready to edit.
Controls: per-model Advanced params (negative prompt, steps, CFG) behind a sliders chip, plus a credit estimate next to Generate (median of your last runs at 0.266 credits/s).
Animate: image results get an Animate action that starts an LTX 2.5 image-to-video job from that image.
Header: GitHub stars and your Comfy credit balance, when connected.
Tracker:
/trackershows what's done and what's next (data intracker/tasks.json).
Tests
From the repository root, run pnpm --filter phaino-studio test for the existing Vitest suite, or pnpm --filter phaino-studio test:e2e for browser tests. e2e starts a separate Studio dev server on port 3100 in demo mode. The tests use bundled samples and need no Comfy credentials. The framework currently supports Windows through WSL.
The e2e GitHub Actions workflow runs affected tests on pull requests using the Filters API. Add the repository secret AI_GATEWAY_API_KEY to enable selection through typesafe-ai/jev. If the key is unavailable, including on fork pull requests, the filter warns and runs the full suite. Pushes to main and manual workflow runs always run the full suite.
To preview selection without starting a browser, commit the changes, then run pnpm --filter phaino-studio exec e2e list --changed-since origin/main with AI_GATEWAY_API_KEY set. The ref must exist locally with enough history to find its merge base.
Repository layout
| 1 | phaino/ |
| 2 | studio/ Studio app (Next.js), the main product |
| 3 | website/ Marketing site (Astro) |
| 4 | presets/ Preset workflows, exported by the M2 pipeline |
| 5 | tracker/ Project task data for /tracker |
| 6 | brand/ Brand kits (brand/phaino) |
| 7 | examples/ Real sample outputs, named <preset-id>_<n>.<ext> |
Hosted demo
Vercel deployments run as a mockup by default. Image, Video, Camera and Workflows use the bundled catalog. You can change models, adjust controls, upload reference images in your browser and preview existing sample media. Samples do not use your prompt or reference images. Library shows sample media and this tab's preview history until reload. Generation, credential entry and server writes are disabled; this is not a hosted generation backend.
Set PHAINO_DEMO=on in studio/.env.local to try the same demo locally. Local use otherwise keeps the real backend. PHAINO_DEMO=off overrides the Vercel default, but requires hosting that supports the app's storage and job runner. On Vercel, use studio/ as the project root and allow files outside that root in the build so Next.js can bundle presets/, models/ and tracker/.
To use another port (3000 is the default): cd studio && pnpm exec next dev -H 127.0.0.1 -p 3100.
Comfy Cloud setup
Create an API key at platform.comfy.org/profile/api-keys and set it as COMFY_API_KEY in studio/.env.local, or paste it into Settings > Comfy Cloud. All built-in presets run on open-weights models on Comfy Cloud and need the model files listed in presets/README.md. Partner presets (Kling, Seedance, Nano Banana) run through Comfy Router and use Comfy credits.
Advanced: your own ComfyUI
To run on your own machine instead, put the Comfy API v2 in front of a local ComfyUI:
| 1 | pip install comfy-api-proxy |
| 2 | comfy-api-proxy |
ComfyUI keeps serving on 127.0.0.1:8188; the proxy serves the Comfy API v2 on 127.0.0.1:8189. Set COMFY_BASE_URL=http://127.0.0.1:8189 in studio/.env.local.
MCP
Connect an MCP client to your local Phaino install at http://127.0.0.1:3000/api/mcp:
| 1 | claude mcp add --transport http phaino http://127.0.0.1:3000/api/mcp |
Tools: list_presets, get_preset, get_workflow, run_preset, get_job. Runs use your configured Comfy account and credits. Upload inputs through the HTTP API first, then pass upload ids to run_preset. This local, single-user endpoint has no authentication; do not expose it publicly. The hosted demo blocks MCP POST requests and cannot run jobs. See /mcp for client configuration and /developers for the HTTP API reference.
Environment variables
All variables live in studio/.env.local (copy studio/.env.example). The old CUTAWAY_DATA_DIR and CUTAWAY_USER names still work as fallbacks.
| Variable | Purpose |
|---|---|
COMFY_API_KEY | Comfy Cloud / Comfy Router API key |
COMFY_BASE_URL | Optional custom Comfy API v2 endpoint (blank = Comfy Cloud) |
PRESETS_DIR | Preset folder (default ../presets from studio/) |
FORKS_DIR | User forks folder (default <PHAINO_DATA_DIR>/forks) |
PHAINO_DEMO | Hosted mockup: on by default on Vercel, off locally. on/off overrides the default |
TRACKER_FILE | Tracker data file (default ../tracker/tasks.json from studio/) |
PHAINO_DATA_DIR | Local data folder (default ./.data under studio/) |
PHAINO_USER | Local user name (default local) |
NEXT_PUBLIC_SITE_URL | Public origin for OG metadata (default https://app.phaino.us.ci; PHAINO_SITE_URL still works as a legacy fallback) |
FFMPEG_PATH | ffmpeg binary for sequence export (default ffmpeg on PATH) |
FFPROBE_PATH | ffprobe binary for sequence export (default ffprobe on PATH) |
Scripts
| Command | What it does |
|---|---|
pnpm dev:studio | Studio dev server on port 3000 |
pnpm dev:website | Website dev server |
pnpm preview:website | Serve the built website |
pnpm build | Build all packages |
pnpm lint | Lint all packages |
pnpm typecheck | Type-check all packages |
pnpm test | Run all tests |
cd studio && pnpm models:sync | Sync template-backed model modes into models/cache |
Presets
Presets live in presets/, one folder per preset (preset.json + exported workflow.json/workflow_api.json + thumb.webp). Schema, binds and the model files each open preset needs are documented in presets/README.md. The workflow files for every built-in model live in the repo: hand-tuned presets under presets/*/workflow.json and template-synced model modes and edit tools under models/cache/ (generated by pnpm models:sync, manifest at models/manifest.json).
Dev: regenerating workflows
workflow.json/workflow_api.json are produced by loading each preset's source template into a ComfyUI instance and exporting via graphToPrompt(). A CPU-only install is enough; no models needed:
| 1 | git clone --depth 1 --branch v0.42.1 https://github.com/comfyanonymous/ComfyUI.git %USERPROFILE%\.cutaway\comfyui |
| 2 | cd %USERPROFILE%\.cutaway\comfyui |
| 3 | python -m venv .venv |
| 4 | .\.venv\Scripts\pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu |
| 5 | .\.venv\Scripts\pip install -r requirements.txt |
| 6 | .\.venv\Scripts\python main.py --cpu --listen 127.0.0.1 --port 8188 |
Then from the repo root: pnpm --filter phaino-studio export:workflows.
Add a model
Models are one line in studio/src/server/models/registry.ts: a mode points at a preset folder or an official Comfy-Org/workflow_templates template:
| 1 | { id: "wan22", label: "Wan 2.2", kind: "video", |
| 2 | modes: { t2v: { template: "video_wan2_2_14B_t2v" } } } |
Then sync the template-backed modes (fetches the template at the pinned TEMPLATES_REF, runs graphToPrompt in a headless ComfyUI, detects prompt/seed/size/duration/image binds automatically, gates on no-API-nodes + public model downloads, and writes models/cache + models/manifest.json):
| 1 | cd studio |
| 2 | pnpm models:sync # use the pinned ref |
| 3 | pnpm models:sync -- --update-ref # pin main's sha first |
Sync reads only; it never queues a generation. A mode that fails a gate stays in the manifest with its reasons and is hidden from the app.
Editor
/editor is a small timeline editor for generated and imported media. It has a video lane with trim, reorder, split (S), duplicate (Ctrl+D), cut/crossfade/dip transitions and per-clip volume, a music lane with fades, a titles lane, aspect (16:9, 9:16, 1:1, 4:5) and contain/cover fitting, a media bin with drag-drop uploads, and undo/redo.
"Render video" produces an H.264/AAC MP4 (drawtext titles, mixed audio, +faststart), and copies it into Library. "Export for NLE" conforms media with handles, writes FCPXML and EDL (crossfades become dissolves), and embeds the rendered movie. The audio lane and titles are not in the FCPXML/EDL interchange files. Title text uses the bundled Outfit font (studio/assets/fonts/Outfit.ttf, OFL). The sequence document lives at <PHAINO_DATA_DIR>/sequence.json (v2; v1 files migrate on load) and uploads land in <PHAINO_DATA_DIR>/uploads/editor/.
Edit Video
/edit is the AI editing bench: each tool takes an existing video (upload or a generated output) and runs one official ComfyUI template: Upscale, Upscale Fast, FPS Boost, Depth Map, Reframe (VACE outpainting to a new aspect), Remove Object (VACE inpainting + SAM3 detect text), Relight and Restyle. Extend is app code: it grabs the clip's last frame with ffmpeg and runs any registered model's image-to-video mode, and the result can join the source in the Editor.
pnpm models:sync gates tools exactly like modes (manifest.json tools key) and caches their workflows; failed tools stay hidden. Clips longer than a tool's limit are trimmed to the first N seconds (H.264 re-encode) before submission. Video uploads land in <PHAINO_DATA_DIR>/uploads/ (mp4/mov/webm, 500 MB).
Marketing site
Astro, TypeScript and Tailwind. pnpm dev:website runs it; it deploys from website/. The visual direction is in website/docs/landing-design.md, and media slots are documented in website/public/media/README.md.
Brand
Brand assets and the guidelines board live in brand/phaino.
Roadmap
The camera moves, image and video tools, job runner, library, editor and Zernio social publishing are built. A hosted generation service is tracked in issue #5. The live list is at /tracker; the data is in tracker/tasks.json.