3D Generation API Documentation

Last Updated: January 4, 2025

Generation Workflows

Single Image Workflow

There are two possible flows when generating from a single image:

Option 1: Direct Generation (No Preview)

  1. POST to /generate_no_preview with your base64 image and parameters
  2. Poll /status until completion
  3. GET /download/model to obtain the final GLB

Option 2: With Preview

  1. POST to /generate_preview with your base64 image and parameters
  2. Poll /status until preview is ready
  3. GET /download/preview/{type} to view the previews
  4. If satisfied, POST to /resume_from_preview
  5. Poll /status until completion
  6. GET /download/model to obtain the final GLB

Multi-Image Workflow

Similarly, there are two flows for multi-image generation:

Option 1: Direct Generation (No Preview)

  1. POST to /generate_multi_no_preview with your base64 images and parameters
  2. Poll /status until completion
  3. GET /download/model to obtain the final GLB

Option 2: With Preview

  1. POST to /generate_multi_preview with your base64 images and parameters
  2. Poll /status until preview is ready
  3. GET /download/preview/{type} to view the previews
  4. If satisfied, POST to /resume_from_preview
  5. Poll /status until completion
  6. GET /download/model to obtain the final GLB

Code Examples

Single Image Generation (Python)

import requests
import base64
import time

# API endpoint
BASE_URL = "http://127.0.0.1:7960"

def generate_no_preview(image_base64: str):
    """Generate 3D model from a single base64-encoded image without previews.
    
    Args:
        image_base64: Base64 string of the image (without 'data:image/...' prefix)
    """
    try:
        # Set generation parameters
        params = {
            'image_base64': image_base64,
            'seed': 42,
            'ss_guidance_strength': 7.5,
            'ss_sampling_steps': 30,
            'slat_guidance_strength': 7.5,
            'slat_sampling_steps': 30,
            'mesh_simplify_ratio': 0.95,
            'texture_size': 1024,
            'output_format': 'glb'
        }
        
        # Start generation
        print("Starting generation...")
        response = requests.post(f"{BASE_URL}/generate_no_preview", data=params)
        response.raise_for_status()
        
        # Poll status until complete
        while True:
            status = requests.get(f"{BASE_URL}/status").json()
            print(f"Progress: {status['progress']}%")
            
            if status['status'] == 'COMPLETE':
                break
            elif status['status'] == 'FAILED':
                raise Exception(f"Generation failed: {status['message']}")
            
            time.sleep(1)
        
        # Download the model
        print("Downloading model...")
        response = requests.get(f"{BASE_URL}/download/model")
        response.raise_for_status()
        
        return response.content
        
    except Exception as e:
        print(f"Error: {str(e)}")
        return None

Multi-Image Generation (Python)

def generate_multi_preview(image_base64_list: list[str]):
    """Generate 3D model from multiple base64-encoded images with previews.
    
    Args:
        image_base64_list: List of base64 strings (without 'data:image/...' prefix)
    """
    try:
        # Set generation parameters
        params = {
            'image_list_base64': image_base64_list,
            'seed': 42,
            'ss_guidance_strength': 7.5,
            'ss_sampling_steps': 30,
            'slat_guidance_strength': 7.5,
            'slat_sampling_steps': 30,
            'preview_resolution': 512,
            'preview_frames': 30,
            'preview_fps': 30,
            'mesh_simplify_ratio': 0.95,
            'texture_size': 1024,
            'output_format': 'glb'
        }
        
        # Start generation with preview
        print("Starting generation...")
        response = requests.post(f"{BASE_URL}/generate_multi_preview", data=params)
        response.raise_for_status()
        
        # Poll until preview is ready
        while True:
            status = requests.get(f"{BASE_URL}/status").json()
            print(f"Progress: {status['progress']}%")
            
            if status['status'] == 'PREVIEW_READY':
                break
            elif status['status'] == 'FAILED':
                raise Exception(f"Generation failed: {status['message']}")
            
            time.sleep(1)
        
        # Download preview video
        print("Downloading preview...")
        preview = requests.get(f"{BASE_URL}/download/preview/gaussian")
        preview.raise_for_status()
        
        # Resume generation to get final model
        print("Resuming generation for final model...")
        resume_params = {
            'mesh_simplify_ratio': 0.95,
            'texture_size': 1024
        }
        response = requests.post(f"{BASE_URL}/resume_from_preview", params=resume_params)
        response.raise_for_status()
        
        # Wait for final model
        while True:
            status = requests.get(f"{BASE_URL}/status").json()
            print(f"Progress: {status['progress']}%")
            
            if status['status'] == 'COMPLETE':
                break
            elif status['status'] == 'FAILED':
                raise Exception(f"Final generation failed: {status['message']}")
            
            time.sleep(1)
        
        # Download final model
        print("Downloading final model...")
        model = requests.get(f"{BASE_URL}/download/model")
        model.raise_for_status()
        
        return {
            'preview': preview.content,
            'model': model.content
        }
        
    except Exception as e:
        print(f"Error: {str(e)}")
        return None

Status Endpoints

GET /ping

Check server status and availability.

Response:
{
    "status": "running",
    "message": "Trellis API is operational",
    "busy": boolean
}
GET /status

Get the status of the current or last generation.

Response:
{
    "status": string,
    "progress": number,
    "message": string,
    "busy": boolean
}

Generation Endpoints

POST /generate_no_preview

Generate a 3D model without previews. Download GLB when complete.

Parameters:
image_base64: string (required)

Base64-encoded image data (without 'data:image/...' prefix)

POST /generate_preview

Generate a 3D structure with previews. Download videos when ready.

Parameters:
image_base64: string (required)

Base64-encoded image data (without 'data:image/...' prefix)

POST /generate_multi_no_preview

Generate a 3D model using multiple images without previews.

Parameters:
image_list_base64: list[string] (required)

List of base64-encoded images (without 'data:image/...' prefix)

POST /generate_multi_preview

Generate previews using multiple images.

Parameters:
image_list_base64: list[string] (required)

List of base64-encoded images (without 'data:image/...' prefix)

POST /resume_from_preview

Continue generation from a preview-ready state to create the final GLB model.

Parameters:
mesh_simplify_ratio: float (0-1, default: 0.95)

Ratio for mesh simplification

texture_size: int (0-4096, default: 1024)

Size of the output texture

Preview Control

POST /interrupt

Cancel the current generation process.

Download Endpoints

GET /download/preview/{type}

Download preview video. Type can be: "gaussian" or "mesh".

GET /download/model

Download the final 3D model (GLB format, with texture).

Common Generation Parameters

seed: int

Random seed for generation

ss_guidance_strength: float (0-10)

Structure sampling guidance strength

ss_sampling_steps: int (0-50)

Structure sampling steps

slat_guidance_strength: float (0-10)

SLAT guidance strength

slat_sampling_steps: int (0-50)

SLAT sampling steps

preview_resolution: int (default: 512)

Resolution for preview renders in pixels

preview_frames: int (15-1000, default: 30)

Number of frames in preview videos

preview_fps: int (default: 30)

Frames per second for preview videos

mesh_simplify_ratio: float (0-1, default: 0.95)

Ratio for mesh simplification. Lower values create simpler meshes

texture_size: int (default: 1024)

Size of the output texture in pixels

output_format: string

Output format, either "glb" or "gltf"