Skip to main content

External Services

Most of LocalGPT Gen runs entirely locally with no external dependencies. Three features require optional local services running on your machine — no cloud APIs, no remote calls.

Overview​

FeatureServiceWhat It DoesGPU Required
NPC IntelligenceOllamaAutonomous NPC behavior via local LLMs2-7 GB
Depth PreviewComfyUIStyled 2D preview from depth maps2-8 GB
3D Asset GenerationModel serverText-to-3D mesh generation5-16 GB

All services run on localhost. No API keys required.

Quick Start​

# Easiest: NPC brains (single binary, no Python)
brew install ollama # or: curl -fsSL https://ollama.ai/install.sh | sh
ollama pull llama3.2:3b

# Moderate: depth-conditioned preview (Python)
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI && pip install -r requirements.txt
python main.py # listens on 127.0.0.1:8188

# Advanced: 3D asset generation (Python + large GPU)
# Any server implementing the model server protocol below, on port 8741

Ollama — NPC Brains​

Attaches autonomous AI brains to NPCs. Each NPC runs a local language model that perceives the scene, reasons about goals, and outputs actions every few seconds.

Install​

# macOS
brew install ollama

# Linux
curl -fsSL https://ollama.ai/install.sh | sh

# Start server (if not already running as service)
ollama serve

# Pull models
ollama pull llama3.2:3b # NPC brain (text-only, 2 GB)

How It Works​

gen_set_npc_brain { entity: "elder", personality: "wise sage" }
→ Spawns brain loop (ticks every 2 seconds):
1. Perceive: gather nearby entities, player distance
2. Build prompt: personality + goals + memories + perception
3. Infer: POST to Ollama localhost:11434/api/chat
4. Parse: extract action (speak, move_to, emote, etc.)
5. Execute: trigger Bevy systems

NPC Actions​

ActionExampleResult
speak("Hello!")Speech bubble, auto-dismiss
move_to(10, 0, 5)Walk to position
look_at("player")Smooth rotation
emote(wave)Animation/particles
interact("door")Trigger interaction system
wanderRandom nearby movement

Supported Models​

ModelVRAMBest For
llama3.2:3b2-3 GBDefault. Good action decisions.
mistral:7b5-7 GBFaster, instruction-tuned.
neural-chat:7b5-6 GBOptimized for dialogue.

Tools​

ToolDescription
gen_set_npc_brainAttach an AI brain to an NPC with personality and goals (fails if Ollama or the model is missing)
gen_npc_observeList what the NPC perceives (named entities in its view cone and radius) and optionally answer a question about it with its model
gen_set_npc_memorySet NPC memory capacity and initial memories

Performance​

  • Max concurrent brains: 4 recommended
  • Distance culling: Brain deactivates when NPC > 50m from player
  • Response latency: ~200-500ms on GPU, ~2-5s on CPU
  • Tick rate: Default 2.0 seconds (configurable per NPC)

Ollama's URL is LOCALGPT_GEN_OLLAMA_URL (default http://localhost:11434). If Ollama stops, brains pause and resume when it is back (checked every 30 seconds).

ComfyUI — Depth Preview​

Generates a styled 2D preview image from a scene's depth map. Lets the AI validate creative direction (colors, mood, style) before committing to full 3D generation.

Install​

git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
pip install -r requirements.txt

# SD 1.5 checkpoint and depth ControlNet, under the names Gen asks for
wget -P models/checkpoints https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
wget -O models/controlnet/control_v11f1p_sd15_depth.safetensors \
https://huggingface.co/lllyasviel/control_v11f1p_sd15_depth/resolve/main/diffusion_pytorch_model.safetensors

python main.py # listens on 127.0.0.1:8188

How It Works​

gen_preview_world { prompt, style_preset }
→ depth map: depth_map_path, or gen_render_depth of the current scene
→ POST /upload/image, POST /prompt (checkpoint + depth ControlNet workflow)
→ poll GET /history/{id}, fetch GET /view
← preview PNG written next to the depth map (or output_path)

If ComfyUI isn't reachable the tool fails with an error; it never returns a path it didn't write.

Configuration​

VariableDefaultPurpose
LOCALGPT_GEN_COMFYUI_URLhttp://127.0.0.1:8188ComfyUI server
LOCALGPT_GEN_COMFYUI_CHECKPOINTv1-5-pruned-emaonly.safetensorsCheckpoint in models/checkpoints/
LOCALGPT_GEN_COMFYUI_CONTROLNETcontrol_v11f1p_sd15_depth.safetensorsDepth ControlNet in models/controlnet/
LOCALGPT_GEN_COMFYUI_WORKFLOW—Your own workflow (API format) instead of the built-in one; {{prompt}}, {{negative}}, {{depth_image}}, {{width}}, {{height}} and {{seed}} are filled in

Style Presets​

PresetStyle
realisticPhotorealistic, high detail, natural lighting
stylizedPixar-style 3D render, vibrant colors
pixel_art16-bit retro game style
watercolorSoft edges, muted colors
concept_artPainterly, atmospheric perspective

GPU Requirements​

  • 2-4 GB VRAM for SD 1.5 + ControlNet
  • 6-8 GB VRAM for SDXL + ControlNet (use a custom workflow)
  • ~10-30 seconds per image at 512x512

Tools​

ToolDescription
gen_render_depthRender a depth map from the current scene
gen_preview_worldGenerate a styled 2D preview from a depth map through ComfyUI

Model Server — 3D Assets​

Generates 3D meshes and PBR textures from text prompts using local open-source models. LocalGPT Gen talks to the server over HTTP; it doesn't ship one, so any server that implements the protocol below works.

How It Works​

gen_generate_asset { prompt: "medieval sword", name: "sword", model: "tripo_sg" }
→ GET /health: fails right away if no server is running
→ POST /generate, returns a task_id; the tool returns at once
↓
Background: poll GET /status/{id} every 2 s (gen_generation_status shows it)
↓
Complete: GET /result/{id}/mesh → workspace/generated/meshes/{task}.glb,
spawned as "sword" at the requested position and scale, saved with the world

gen_generate_texture { entity, prompt } works the same way and, on completion, downloads the maps it reports (base_color, metallic_roughness, normal, emissive) into workspace/generated/textures/ and puts them on the entity's material. Saving the world copies them into its assets/textures/.

Protocol​

Base URL LOCALGPT_GEN_MODEL_SERVER (default http://127.0.0.1:8741).

RequestResponse
GET /health200 with any JSON ({"status": "ok", ...})
POST /generate{"task_id": "..."}
GET /status/{id}{"status": "queued" | "generating" | "complete" | "failed", "progress": 0.4, "error": "...", "outputs": ["mesh"]}
GET /result/{id}/{output}The file: mesh is a GLB, texture maps are PNGs
POST /cancel/{id}Anything

POST /generate bodies:

{ "type": "mesh", "prompt": "medieval sword", "model": "tripo_sg",
"quality": "standard", "pbr": true, "output_format": "glb",
"reference_image": null }

{ "type": "texture", "prompt": "mossy stone", "style": "realistic",
"resolution": 1024, "shape": { "Cuboid": { "x": 1, "y": 1, "z": 1 } } }

reference_image is base64 image data or null; shape is the target's parametric shape, or null for imported meshes.

Supported Models​

ModelVRAMSpeed (standard)Output
TripoSG8 GB30sMesh only
Hunyuan3D 2mini5-6 GB45sMesh + PBR textures
Hunyuan3D 2.110 GB60sFull PBR
Step1X-3D16 GB90sMesh + PBR + LoRA

Tools​

ToolDescription
gen_generate_assetQueue a 3D mesh generation task
gen_generate_textureQueue PBR texture maps for an entity
gen_generation_statusCheck progress, list tasks, or cancel one

📝 These docs are AI-generated on a best-effort basis and may not be 100% accurate. Found an issue? Please open a GitHub issue or edit this page directly to help improve the project.