Skip to content

Python SDK

Use the SuperStyle API from Python with the requests library.

Terminal window
pip install requests
import requests
API_KEY = "ss_your_key_here"
BASE_URL = "https://mcll3bnfubyazfg6wekv3xc6fi0dgpyk.lambda-url.us-east-1.on.aws"
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
# Identify clothing in an image
response = requests.post(
f"{BASE_URL}/identify_clothing",
headers=headers,
json={"image_url": "https://example.com/outfit.jpg"}
)
data = response.json()
for item in data["items"]:
print(f"{item['item']}: {item['color']}{item['description']}")
for product in item.get("products", []):
print(f" Buy: {product['title']} ({product.get('price', 'N/A')}) → {product['url']}")

A minimal wrapper for convenience:

import requests
import base64
from pathlib import Path
class SuperStyleClient:
def __init__(self, api_key: str, base_url: str = "https://mcll3bnfubyazfg6wekv3xc6fi0dgpyk.lambda-url.us-east-1.on.aws"):
self.base_url = base_url
self.headers = {
"X-API-Key": api_key,
"Content-Type": "application/json",
}
def _post(self, endpoint: str, data: dict) -> dict:
response = requests.post(
f"{self.base_url}{endpoint}",
headers=self.headers,
json=data,
)
response.raise_for_status()
return response.json()
def _get(self, endpoint: str) -> dict:
response = requests.get(
f"{self.base_url}{endpoint}",
headers=self.headers,
)
response.raise_for_status()
return response.json()
def identify_clothing(self, image_url: str) -> list[dict]:
"""Analyze an outfit image and return identified items."""
data = self._post("/identify_clothing", {"image_url": image_url})
return data["items"]
def generate_image(
self,
selfie_path: str,
clothing_description: str,
mode: str = "studio",
clothing_image_url: str | None = None,
) -> tuple[bytes, str]:
"""Generate a try-on image. Returns (image_bytes, mime_type)."""
selfie_b64 = base64.b64encode(Path(selfie_path).read_bytes()).decode()
payload = {
"selfie_base64": selfie_b64,
"clothing_description": clothing_description,
"mode": mode,
}
if clothing_image_url:
payload["clothing_image_url"] = clothing_image_url
data = self._post("/generate_image", payload)
image_bytes = base64.b64decode(data["image_base64"])
return image_bytes, data["mime_type"]
def style_me(
self,
selfie_path: str,
style_preferences: str | None = None,
occasion: str | None = None,
num_outfits: int = 3,
) -> list[dict]:
"""Get personalized outfit suggestions."""
selfie_b64 = base64.b64encode(Path(selfie_path).read_bytes()).decode()
payload = {"selfie_base64": selfie_b64, "num_outfits": num_outfits}
if style_preferences:
payload["style_preferences"] = style_preferences
if occasion:
payload["occasion"] = occasion
data = self._post("/style_me", payload)
return data["outfits"]
def usage(self) -> dict:
"""Get API usage statistics."""
return self._get("/usage")
client = SuperStyleClient("ss_your_key_here")
# Identify clothing
items = client.identify_clothing("https://example.com/outfit.jpg")
# Generate try-on
image_bytes, mime_type = client.generate_image(
selfie_path="selfie.jpg",
clothing_description="Black leather jacket",
mode="studio",
)
with open("tryon.jpg", "wb") as f:
f.write(image_bytes)
# Get style recommendations
outfits = client.style_me("selfie.jpg", occasion="date night")
for outfit in outfits:
print(outfit["description"])
# Check usage
stats = client.usage()
print(f"Total requests: {stats['total_requests']}")