InstantSplat / TYPESCRIPT_QUICKSTART.md
Long Hoang
Use Supabase for outputs and add Python/TS API clients
1575924

A newer version of the Gradio SDK is available: 6.12.0

Upgrade

TypeScript API Client - Quick Start

✅ Fixed and Ready to Use!

The TypeScript API client is now working. Here's how to use it:

🚀 Usage

Option 1: With Environment Variable (Recommended)

# Set your Space URL
export INSTANTSPLAT_SPACE="your-username/InstantSplat"

# Run the client
npm run api test01/IMG_8533.jpeg test01/IMG_8534.jpeg test01/IMG_8535.jpeg

Option 2: Programmatic Usage

import { processImages } from "./api_client.js";

const result = await processImages(
  ["img1.jpg", "img2.jpg", "img3.jpg"],
  "your-username/InstantSplat"  // Specify Space URL here
);

if (result.status === "success") {
  console.log("GLB URL:", result.glb_url);
  console.log("PLY URL:", result.ply_url);
}

Option 3: Local Instance

If running the app locally:

# Terminal 1: Start the app
python app.py

# Terminal 2: Use the client (no Space URL needed)
npm run api img1.jpg img2.jpg img3.jpg

🔧 What Was Fixed

  1. ✅ Fixed @gradio/client import (uses client function, not Client class)
  2. ✅ Fixed ES module compatibility (import.meta.url instead of require.main)
  3. ✅ Updated all examples and documentation

📝 Complete Example

import { processImages, completeWorkflow } from "./api_client.js";

// Example 1: Get URLs only
async function getURLs() {
  const result = await processImages(
    ["img1.jpg", "img2.jpg", "img3.jpg"],
    "your-username/InstantSplat"
  );
  
  if (result.status === "success") {
    return {
      glb: result.glb_url,
      ply: result.ply_url
    };
  }
}

// Example 2: Process and download
async function processAndDownload() {
  const localPath = await completeWorkflow(
    ["img1.jpg", "img2.jpg", "img3.jpg"],
    "./models",
    "your-username/InstantSplat"
  );
  
  console.log("Model saved to:", localPath);
}

🎯 Next Steps

  1. Deploy your Space to HuggingFace
  2. Get your Space URL (e.g., username/InstantSplat)
  3. Run the client with your Space URL
  4. Integrate into your TypeScript/JavaScript application

📚 Full Documentation

  • API_TYPESCRIPT.md - Complete TypeScript API reference
  • example_api_usage.ts - Working examples
  • README_TS.md - General TypeScript client guide