Skip to main content

Batch Staging

Stage multiple room images in parallel for maximum throughput.

Python example

import requests
import concurrent.futures
from pathlib import Path

API_KEY = "sk_live_xxxxxxxxxxxxx"
BASE_URL = "https://stagingspaces-production-6fb7.up.railway.app"

def stage_image(image_path, style="modern"):
    """Stage a single image. Returns result dict."""
    with open(image_path, "rb") as f:
        response = requests.post(
            f"{BASE_URL}/api/v1/stage",
            headers={"Authorization": f"Bearer {API_KEY}"},
            files={"image": f},
            data={"style": style}
        )
    result = response.json()
    result["source_file"] = str(image_path)
    return result

def batch_stage(image_dir, style="modern", max_workers=5):
    """Stage all images in a directory concurrently."""
    images = list(Path(image_dir).glob("*.jpg")) + list(Path(image_dir).glob("*.png"))
    results = []

    with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
        futures = {
            executor.submit(stage_image, img, style): img
            for img in images
        }

        for future in concurrent.futures.as_completed(futures):
            result = future.result()
            if result.get("success"):
                print(f"✓ {result['source_file']}{result['claim_code']}")
            else:
                print(f"✗ {result['source_file']}: {result.get('error')}")
            results.append(result)

    return results

# Stage all images in a folder
results = batch_stage("./property_photos/", style="scandinavian", max_workers=5)

# Collect claim codes
claim_codes = [r["claim_code"] for r in results if r.get("success")]
print(f"\nStaged {len(claim_codes)} images")
print(f"Claim codes: {', '.join(claim_codes)}")

Rate limits

  • 60 requests/minute per API key
  • 10 concurrent staging jobs max
  • Set max_workers=5 for optimal throughput without hitting limits

Tips

  • Check your credit balance before batch staging to avoid partial failures
  • Use auto top-up to prevent interruptions during large batches
  • Each image gets its own claim code — or you can collect them for the agent