Hat and cap try-on API: one selfie, one call per colorway
Let shoppers see a cap or beanie on their own head: one selfie plus one product photo per colorway, a cache key per shopper, SKU and colour, and a cost log.

Headwear is an easy accessory to preview: the face stays visible and the item covers only a small area. ChatGPT Try On, launched 1 October 2026 with a selfie or full-body photo as input (TechCrunch, read 2026-10-04), covers accessories in general. For a shop that sells caps, the question is how to run that inside the product page, per colorway.
The pattern on Sume is one image edit per colorway, each with the shopper's selfie and that colorway's product photo as two references.
One call per colour
Keep the loop outside the model. A shopper who taps the navy, olive and sand caps triggers three requests, each with its own product photo. That keeps every result tied to a specific SKU and colour, which a single prompt listing three colours cannot promise.
import os, requests
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
resp = requests.post("https://api.sume.com/v1/images", headers=H, timeout=90, json={
"model": "openai/gpt-image-2.5",
"prompt": "Image 1 is the shopper. Image 2 is a navy baseball cap. Put the cap on the shopper's head, brim forward, sitting naturally over the hair. Keep the logo on the cap as in image 2. Keep face, clothing and background from image 1.",
"input_references": [
{"type": "image_url", "image_url": {"url": "https://example.com/selfie.jpg"}},
{"type": "image_url", "image_url": {"url": "https://example.com/cap-navy.jpg"}}
],
"aspect_ratio": "auto",
})
resp.raise_for_status()
if resp.status_code == 202:
raise SystemExit("job envelope: poll data.status_url")
body = resp.json()
print([d["url"] for d in body["data"]], body.get("usage"))Idempotency and cost
Retries happen when a shopper double-taps. On Sume, POST /v1/images blocks for up to 30 seconds and returns the images, or returns a 202 job envelope after that. For the video endpoints Sume documents an Idempotency-Key header; for images, make your own key from shopper id, SKU and colour and cache the first result under it, so a double tap costs one call.
Log usage.cost from each response against the same key, and cap the colours per session so one shopper cannot run a long chain.
What to check
- The logo is the same size and position as on the product photo.
- Hair is not cut off or turned into a hat texture.
- The brim does not cover the eyes unless the product is meant to.
- The shopper's face is unchanged between the colour variants.
Sources
Related posts
More in Use cases
- Haunted house ticket teaser: three stills, one 18 s render, $2.68
A haunted house or trail promo from three photos: Wan 3.0 clips at $0.125 a second, a Timeline render, a music bed and burned-in dates. $2.675 in total.
- Headphone and earbud product photos: logo and orientation QC
Make headphone or earbud lifestyle shots with Sume's image API, then catch flipped logos, wrong earcup sides and cable errors with a Pillow contact sheet.
- HeyGen Free: 3 videos of 1 minute to test a script
HeyGen's Free plan lists 3 videos a month up to a minute. Use them to judge a script's pacing, then check it against Sume's 4 to 60 second window.
- Holiday ad voiceover and music bed: cost per spot, 300-900 chars
On Sume a 600-character voiceover costs $0.0285 and a music track $0.125 flat, so a spot with both is $0.1535, before the video.
Written by Sume