Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
"""
three.ws Forge FastAPI backend.
Runs locally within the Electron app to provide AI inference endpoints.
"""
import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
from services.stdio_utf8 import ensure_utf8_stdio
ensure_utf8_stdio() # must run before any print/logging hits the pipe
from access_control import install_access_control, register_workspace_route
from routers import generation, model, optimize, status, settings, extensions, export, workflow_runs, agent, llm
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup: initialize the registry (instantiates all adapters)
from services.generator_registry import generator_registry
generator_registry.initialize()
yield
# Shutdown: unload all models and stop the local LLM server
generator_registry.unload_all()
from services.llm_server import llama_pool
llama_pool.unload_all(force=True)
class _StatusFilter(logging.Filter):
def filter(self, record):
return "/generate/status/" not in record.getMessage()
logging.getLogger("uvicorn.access").addFilter(_StatusFilter())
app = FastAPI(
title="three.ws Forge API",
version="0.4.3",
lifespan=lifespan,
)
install_access_control(app)
app.include_router(status.router)
app.include_router(settings.router)
app.include_router(model.router, prefix="/model")
app.include_router(generation.router, prefix="/generate")
app.include_router(optimize.router, prefix="/optimize")
app.include_router(extensions.router, prefix="/extensions")
app.include_router(export.router, prefix="/export")
app.include_router(workflow_runs.router, prefix="/workflow-runs")
app.include_router(agent.router)
app.include_router(llm.router, prefix="/llm")
# Serve generated files from workspace (contained to the workspace directory)
register_workspace_route(app)