managarten/services/mana-image-gen/README.md
Till JS 3c91691d26 fix(mana-image-gen): align source default port with production reality
Source default was 3026 but Mac Mini production has been overriding to
3025 via the launchd plist in scripts/mac-mini/setup-image-gen.sh ever
since the service was set up. The override existed in exactly one place
that is not version-controlled in any obvious way — anyone redeploying
without that script would land on 3026 and clients pointing at 3025
would fail to connect.

Source default → 3025 across main.py, setup.sh, README, CLAUDE.md so the
launchd plist is no longer load-bearing. The Mac Mini setup script still
sets PORT=3025 explicitly; that's now belt-and-suspenders rather than the
only thing keeping production alive.

Also added a note clarifying that this Mac Mini service (flux2.c, MPS,
arm64-only) is *not* the same thing as the "image-gen" running on the
Windows GPU server (PyTorch + diffusers + CUDA, port 3023, code lives at
C:\mana\services\mana-image-gen\ outside this repo). Two different
implementations sharing a name was confusing the port-collision audit.

Updated docs/PORT_SCHEMA.md warning block to retract the previous false
claims of two active port collisions:

  - image-gen ↔ video-gen on 3026 — wrong: image-gen runs on Mac Mini
    on 3025 (now also the source default), video-gen is alone on the
    Windows GPU on 3026
  - voice-bot ↔ sync on 3050 — latent only: mana-voice-bot is not
    deployed anywhere (no launchd, no scheduled task, no cloudflared
    route), so the collision is in source defaults but not in production

The voice-bot 3050 default should still be moved before voice-bot is
ever deployed — flagged in the PORT_SCHEMA warning instead of silently
fixed since voice-bot deployment is its own decision.
2026-04-08 12:30:33 +02:00

2.1 KiB

Mana Image Generation Service

Local AI image generation using FLUX.2 klein 4B model via flux2.c.

Features

  • Fast: Sub-second generation on Apple Silicon
  • Efficient: ~4-5 GB RAM (memory-mapped weights)
  • Open: Apache 2.0 license (commercial use)
  • Local: 100% on-device, no API keys needed

Requirements

  • macOS with Apple Silicon (M1/M2/M3/M4)
  • 16 GB RAM minimum
  • ~20 GB disk space (model + binary)
  • Python 3.11+

Quick Start

# 1. Run setup (installs flux2.c + downloads model)
./setup.sh

# 2. Start the service
source .venv/bin/activate
FLUX_BINARY=/opt/flux2/flux FLUX_MODEL_DIR=/opt/flux2/model \
  uvicorn app.main:app --host 0.0.0.0 --port 3025

# 3. Generate an image
curl -X POST http://localhost:3025/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "A cat wearing sunglasses"}' | jq

API

Generate Image

POST /generate
Content-Type: application/json

{
  "prompt": "A beautiful mountain landscape",
  "width": 1024,
  "height": 1024,
  "steps": 4,
  "seed": -1,
  "output_format": "png"
}

Response:

{
  "success": true,
  "image_url": "/images/abc123.png",
  "prompt": "A beautiful mountain landscape",
  "width": 1024,
  "height": 1024,
  "steps": 4,
  "seed": 42,
  "generation_time": 0.85
}

Get Image

GET /images/{filename}

Health Check

GET /health

Model Info

GET /models

Environment Variables

Variable Default Description
PORT 3025 Service port
FLUX_BINARY /opt/flux2/flux flux2.c binary path
FLUX_MODEL_DIR /opt/flux2/model Model weights path
DEFAULT_STEPS 4 Sampling steps
DEFAULT_WIDTH 1024 Default width
DEFAULT_HEIGHT 1024 Default height

Model

FLUX.2 klein 4B by Black Forest Labs (January 2026)

  • 4 billion parameters
  • Apache 2.0 license
  • Optimized for 4 sampling steps
  • Sub-second inference on consumer GPUs

Credits