Self-hosted multi-user AI studio built on FastAPI and ComfyUI.
- Image, video, music, SFX, and TTS generation workflows.
- Personal generation chats with inline results.
- Shared gallery with likes, comments, privacy controls, share links, and ZIP downloads.
- Built-in direct messages, profiles, posts, follows, and notifications.
- Prompt Enhancer with Google AI Studio and OpenRouter fallbacks.
- Separate LLM chat area with provider failover.
- Admin panel for user management, moderation, and maintenance mode.
- Python + FastAPI
- SQLite
- ComfyUI
- Jinja templates + static frontend assets
- Copy
.env.exampleto.env. - Set a strong
APP_SECRET. - Before the first launch, set:
INITIAL_ADMIN_USERNAME=admin
INITIAL_ADMIN_PASSWORD=change-this-before-launch
INITIAL_ADMIN_NICKNAME=Administrator- Add any API keys you want to use.
- Start ComfyUI on
127.0.0.1:8188. - Start Apex.ai with
run.baton Windows or./run.shon Linux/macOS. - Open http://127.0.0.1:8000.
The first admin account is created automatically only when the database is empty and INITIAL_ADMIN_USERNAME plus INITIAL_ADMIN_PASSWORD are set.
Important variables:
APP_SECRET=replace-with-a-long-random-secret
INITIAL_ADMIN_USERNAME=
INITIAL_ADMIN_PASSWORD=
INITIAL_ADMIN_NICKNAME=Administrator
GOOGLE_AI_STUDIO_API_KEY=
OPENROUTER_API_KEY=
GROQ_API_KEY=
OLLAMA_API_KEYS=Optional bulk user seed:
FRIEND_USERS=alice:password123,bob:password456
FRIEND_NICKNAMES=alice:Alice,bob:Bob
ADMIN_USERS=alice
NO_GALLERY_USERS=
NO_PUBLISH_USERS=Tunnel autostart is disabled in .env.example on purpose. Turn it on only if you really want to expose the site publicly.
Example:
TUNNEL_AUTOSTART=true
TUNNEL_PROVIDER=localhostrun
LOCALHOST_RUN_USER=nokey@localhost.runCloudflare named tunnels are also supported:
TUNNEL_PROVIDER=cloudflared
CLOUDFLARED_TUNNEL_TOKEN=your-cloudflare-tokenExpose only Apex.ai. Do not expose the ComfyUI 8188 port directly.
app/application codetemplates/Jinja templatesstatic/frontend assetsworkflows/ComfyUI API workflowsconfig/models.jsonavailable models
Runtime files such as .env, SQLite databases, logs, tunnels, and generated media are ignored by .gitignore and should not be committed.
This repository is prepared for public publishing:
- real secrets are expected only in local
.env - example config no longer contains personal logins or passwords
- no default public tunnel is enabled
- no hardcoded default admin account is created from code
- The database is created automatically at
data/app.sqlite3. - Media files are stored under
media/. - Audio workflows live in
workflows/and require matching ComfyUI models/custom nodes.