For the complete documentation index, see llms.txt. This page is also available as Markdown.

Mesh

Upload one mesh

Use POST /uploads to get a presigned URL. Upload the bytes to that URL, then poll GET /uploads/{asset_id} until the status is ready.

file="model.glb"
size=$(wc -c < "$file")
upload=$(curl -sS "$MARSO_API_BASE_URL/uploads" \
  -H "Authorization: Bearer $MARSO_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"filename\":\"$file\",\"size_bytes\":$size}")
upload_args=()
while IFS= read -r header; do upload_args+=(--header "$header"); done < <(
  echo "$upload" | jq -r '.headers | to_entries[] | "\(.key): \(.value)"'
)
curl -sS "$(echo "$upload" | jq -r .upload_url)" "${upload_args[@]}" --upload-file "$file"
asset_id=$(echo "$upload" | jq -r .asset_id)
while :; do
  status=$(curl -sS "$MARSO_API_BASE_URL/uploads/$asset_id" \
    -H "Authorization: Bearer $MARSO_API_KEY")
  state=$(echo "$status" | jq -r .status)
  [[ "$state" != "pending" ]] && break
  sleep 2
done
echo "$status"
import os
from pathlib import Path
import time
import requests

base = os.environ["MARSO_API_BASE_URL"]
headers = {"Authorization": f"Bearer {os.environ['MARSO_API_KEY']}"}
path = Path("model.glb")
data = path.read_bytes()
upload = requests.post(
    f"{base}/uploads", headers=headers,
    json={"filename": path.name, "size_bytes": len(data)}, timeout=30
).json()
requests.put(upload["upload_url"], headers=upload["headers"], data=data, timeout=300).raise_for_status()
while True:
    status = requests.get(f"{base}/uploads/{upload['asset_id']}", headers=headers, timeout=30).json()
    if status["status"] == "ready":
        break
    if status["status"] == "rejected":
        raise RuntimeError("mesh validation failed")
    time.sleep(2)

Download and unzip the USDZ mesh result

Submit the ready asset to POST /pbr/execute/mesh. Poll the execution until it reaches a terminal status, then download usdz.download_url.

Upload a batch

Use POST /batch/uploads for 5 to 200 files. Upload each file to its returned URL, then poll GET /batch/uploads/{upload_batch_id}.

Last updated