Use this path if you want a clean first-run setup with the required KIE API dependency and local database created for you.
Before you start, make sure this Mac has:
- Git
- Python 3
- Node.js LTS
If you want a short prerequisites page first:
If Git is missing, run:
xcode-select --installIf Node.js is missing, install the LTS release from:
git clone https://github.com/gateway/media-studio.git
cd media-studio./scripts/onboard_mac.shThe script will:
- reuse an existing sibling
../kie-apior../kie-ai/kie_codex_bootstrapcheckout when present - clone
gateway/kie-apibeside this repo if no supported sibling checkout exists - create or reuse the shared Python virtualenv
- install Python dependencies plus the web app workspace dependencies
- create
.envif it does not exist - create a clean local SQLite database with schema and default presets
- prompt for your Kie AI API key
- report Codex Local availability on this machine
- optionally set Codex Local as the default local AI provider for prompt enhancement and Prompt Recipe drafting
- leave OpenRouter and local OpenAI-compatible endpoints for later setup in
Settings -> AI
The shared Python virtualenv includes editable installs of:
kie-apimedia-studio-api
Test-only packages are installed later only when you run the quality or release verification scripts.
Committed verification tooling such as Vitest stays out of the normal user path until you run the quality or release verification workflow.
Live generation requires KIE_API_KEY.
Get a key here:
If you skip this during onboarding, Media Studio stays in offline-safe mode until you add the key later.
During onboarding, the macOS script checks whether Codex Local is ready. If it is ready, the script can set Codex Local as the default local provider for prompt enhancement and Prompt Recipe drafting.
OpenRouter and local OpenAI-compatible endpoints are still supported, but they are advanced setup paths that should be wired later in Settings -> AI.
Provider paths:
- Codex Local through your local
codexlogin OPENROUTER_API_KEYfor hosted enhancement and draftingMEDIA_LOCAL_OPENAI_BASE_URLand optionalMEDIA_LOCAL_OPENAI_API_KEYfor a local OpenAI-compatible endpoint
Users can still generate media without prompt enhancement.
If you need to revisit any provider choice later, open the AI settings URL printed by the launcher. On a default free-port launch, that is http://127.0.0.1:3000/settings/llms.
If you choose the launch option at the end of onboarding, the script uses one launcher Terminal window for normal Mac use.
That launcher starts:
- the FastAPI control API
- the Next.js web app
behind one Terminal window, and it opens the browser to /studio.
Before launching, the script checks whether the configured API and web ports are already in use. If a default port is busy, the launcher chooses the next open local port for that launch and prints the actual Studio URL. If you pass explicit ports, startup stays strict and asks you to choose another pair when one is busy.
Friend-friendly launchers from the repo root:
Start Media Studio.commandStop Media Studio.command
Start Media Studio.command uses one launcher Terminal window on macOS, starts both the API and web processes in production mode, waits for Studio to be ready, and opens the browser to /studio.
If you prefer Terminal but still want the normal user path, run:
./scripts/run_studio_mac.shThat script runs the local app in production mode, waits for it to become ready, and opens the browser to /studio.
If the default ports are already in use by another app, the normal macOS launcher automatically chooses the next available temporary ports and prints the actual Studio URL. To force a specific pair instead, pass it directly:
./scripts/run_studio_mac.sh --api-port 8010 --web-port 3010The startup scripts now derive the web control API URL from the chosen API host and port automatically, so you do not need to manually edit every related base URL when you just want alternate local ports.
If you want the friendlier launcher behavior with the same override:
./scripts/open_studio_mac.sh --api-port 8010 --web-port 3010If you close the launcher window by mistake or something gets stuck locally, the easiest recovery path is:
Stop Media Studio.command- then
Start Media Studio.command
The Mac launcher now also tries to auto-clean stale local Media Studio processes if only the API or only the web app is still running.
For normal use, prefer Start Media Studio.command or ./scripts/run_studio_mac.sh. Use hot-reload mode only when you are actively editing the code:
npm run devThat path runs the API and web app together with hot reload, so you may see dev-only UI such as the Next badge or overlay.
Then open the URL printed by the launcher. On a default free-port launch, that route is:
http://127.0.0.1:3000/studio
If port 3000 is busy, the launcher picks another web port and prints the actual temporary Studio URL.
If you want to open Studio from another device on your private LAN or TailScale network, add this to .env:
MEDIA_STUDIO_ALLOW_PRIVATE_NETWORK_ACCESS=trueWhen private network access is enabled, Studio also allows active LAN/TailScale IPv4 addresses for Next.js development hydration. If your adapter or proxy is unusual, add the phone-visible host explicitly:
MEDIA_STUDIO_ALLOWED_DEV_ORIGINS=100.64.x.yThen restart Studio with:
./scripts/stop_studio_mac.sh
./scripts/run_studio_mac.shFor an alternate port pair, stop and start with the same explicit values:
./scripts/stop_studio_mac.sh --api-port 8010 --web-port 3010
./scripts/run_studio_mac.sh --api-port 8010 --web-port 3010If you are using dev mode instead of the normal production-style launcher, also set:
MEDIA_STUDIO_WEB_HOST=0.0.0.0If you prefer browser auth instead of the private-network flag, use:
MEDIA_STUDIO_ADMIN_USERNAME=your_user
MEDIA_STUDIO_ADMIN_PASSWORD=your_passwordMedia Studio will route you automatically:
- to
/setupif this machine still needs configuration - to
/studioonce the API, models, and live key are ready
Back up the current local database:
./scripts/backup_db.shGenerate a clean schema-only database:
./scripts/create_clean_db.sh --output ./data/backups/media-studio-clean.sqlite --overwriteThe repo should not commit local runtime databases, uploads, downloads, or outputs. Those stay local and ignored.