Trellis2-StableProjectorz API

Version: 1.0.0  |  Default port: 7960  |  Launch: python api_spz/main_api.py --host 127.0.0.1 --port 7960

Wraps Microsoft TRELLIS.2-4B for use with StableProjectorz. Trellis 2 always generates shape + PBR texture in a single pass. Output is GLB with baked base color, metallic, and roughness maps.

Generation Workflow

Typical Flow

All generation endpoints are synchronous — they block until generation completes and return the result directly. Polling GET /status is optional and only useful for monitoring progress from a separate connection during a long generation.

StableProjectorz UI (recommended)

  1. SPZ fetches GET /download/spz-ui-layout/generation-3d-panel to build the UI panel
  2. User configures parameters and submits image(s)
  3. SPZ sends POST /generate with JSON body containing all parameters + base64 images
  4. Response arrives when generation is complete, containing model_url
  5. SPZ downloads the GLB via GET /download/model

Direct API usage

  1. POST /generate_no_preview (single image) or POST /generate_multi_no_preview (multi-image) with form data
  2. Response arrives when complete — contains "model_url": "/download/model"
  3. GET /download/model to retrieve the GLB
Trellis 2 is single-image only. Multi-image endpoints accept multiple images but use only the first one.
Only one generation can run at a time. A second request while busy returns 503.

Endpoints

GET /ping

Health check. Returns server status and whether a generation is in progress.

Response:
{
    "status": "running",
    "message": "Trellis2 API is operational",
    "busy": false
}
GET /status

Returns the status of the current or most recent generation. Useful for progress monitoring from a separate connection while a generation endpoint is blocking.

Response:
{
    "status": "PROCESSING" | "COMPLETE" | "FAILED",
    "progress": 0-100,
    "message": "Generating 3D mesh and texture...",
    "busy": true
}
POST /generate

Primary endpoint used by StableProjectorz. Accepts a JSON body with all parameters and base64-encoded images. Blocks until generation completes.

Request body (JSON):
{
    "seed": 1234,
    "guidance_scale": 7.5,
    "num_inference_steps": 12,
    "resolution": 1,
    "mesh_simplify": 50,
    "apply_texture": true,
    "single_multi_img_input": ["data:image/png;base64,iVBOR..."]
}
seed (int) — Random seed for reproducibility.
guidance_scale (float, 1–10) — Controls sparse structure guidance strength. Higher = more faithful to input image.
num_inference_steps (int, 1–50) — Sampling steps applied uniformly to all 3 pipeline stages (sparse structure, shape, texture).
resolution (int) — Dropdown index: 0 = 512, 1 = 1024, 2 = 1536. Maps to pipeline types 512, 1024_cascade, 1536_cascade.
mesh_simplify (int, 10–500) — Decimation target in thousands of faces. E.g. 50 = 50,000 faces.
apply_texture (bool) — Present for UI consistency. Trellis 2 always generates texture; this flag has no effect.
single_multi_img_input (list of strings) — Base64-encoded images. Only the first image is used.
Response:
{
    "status": "COMPLETE",
    "progress": 100,
    "message": "Generation complete",
    "model_url": "/download/model"
}
POST /generate_no_preview

Direct generation from a single image via multipart form data. Blocks until generation completes.

Form parameters:
file (UploadFile, optional) — Image file upload.
image_base64 (string, optional) — Base64-encoded image. Provide either file or image_base64.
seed (int, default 1234)
guidance_scale (float, default 7.5)
num_inference_steps (int, default 12)
resolution (int, default 1024) — Raw value: 512, 1024, or 1536. Values are snapped to the nearest valid option.
mesh_simplify (int, default 50) — In thousands of faces.
texture_size (int, default 2048) — Baked texture resolution in pixels.
output_format (string, default "glb") — Only GLB is supported.
Response: Same as /generate.
POST /generate_multi_no_preview

Accepts multiple images via multipart form data. Trellis 2 uses only the first image. Blocks until generation completes.

Form parameters:
file_list (list of UploadFile, optional) — Multiple image file uploads.
image_list_base64 (list of strings, optional) — Multiple base64-encoded images.
All other parameters same as /generate_no_preview.
Response: Same as /generate.
POST /interrupt

Cancel the current generation. The cancellation is injected between sampling steps and typically takes effect within 1–2 seconds. The blocked generation endpoint will return 499.

Response:
{"status": "interrupt_requested"}
// or if nothing is running:
{"status": "no_generation_in_progress"}
GET /download/model

Download the generated GLB file. Available after generation completes successfully. Returns 404 if no model exists.

Response: Binary GLB file (model/gltf-binary), with PBR textures stored as PNG.
GET /download/spz-ui-layout/generation-3d-panel

Returns the StableProjectorz UI layout definition as plain text. SPZ uses this to dynamically build the generation panel with sliders, dropdowns, and toggles.

Response: Plain text (text/plain; charset=utf-8).
GET /info/supported_operations

Returns the list of supported operation types. Trellis 2 always generates mesh with texture in a single pass.

Response:
["make_meshes_and_tex"]

Pipeline Defaults Reference

Trellis 2 runs three sampling stages internally. The SPZ UI exposes guidance_scale (controls sparse structure guidance) and num_inference_steps (applied to all stages). All other sampler parameters are hardcoded to match the official Gradio app defaults:

Stageguidance_strengthguidance_rescalestepsrescale_t
1. Sparse Structureuser slider (def 7.5)0.7user slider (def 12)5.0
2. Shape7.50.5user slider (def 12)3.0
3. Texture1.00.0user slider (def 12)3.0
Resolution mapping: 512 → pipeline type 512  |  1024 → 1024_cascade  |  1536 → 1536_cascade
GLB export: Remeshing enabled (remesh_band=1, remesh_project=0). Mesh simplified to nvdiffrast limit (16M triangles) before export, then decimated to user-specified face count. PBR texture baked from the voxel attribute volume via trilinear sampling. Textures stored as PNG inside the GLB.

Error Codes

CodeMeaning
400Invalid parameters or missing image
404Model file not found (no generation completed yet)
499Generation cancelled by user via /interrupt
500Internal server error during generation
503Server busy — another generation is already running