Render a look
/v2/agent/looksRenders one outfit as a single styled image of a model wearing every
item, from the product photos alone. Call it once for each look
announced on a looks stream event (or in the non-streaming
response's looks), passing that look's item ids, label and
customInstructions. Fire the calls in parallel — each takes several
seconds and they are independent, so a three-look answer finishes about
as fast as a one-look answer.
The endpoint is not limited to agent output: any two to six active
items from your catalogue can be rendered together, or a single dress
or jumpsuit on its own, which is shown in the store's own model photo
of it when there is one (see Visualization). One item is also enough
when the look is completed by a piece of the shopper's own
(ownPiece) or by one of the store's house basics other than shoes
(basics). itemIds must be full item ids (the itemId on a
Product), not the 13-character references the agent uses in its
tool calls.
Items are resolved within your organization's datasets only. Every id
must resolve to an active item in scope, or the request fails with
404 naming the ids that did not — a look is never rendered with
pieces missing. When rendering a look from the agent, send the same
datasetIds you sent to the chat endpoint; the agent picked its items
from that scope, and the default (your active datasets) may not
contain them.
The image
The image is generated at 3:4 by default so nothing is cropped
when displayed in a portrait box; preferences.aspectRatio can ask
for 1:1 instead; any other value is refused with 422. With
userPhotoUrl the render keeps the shape of the shopper's photo. A new render is returned inline as a data: URI
in imageData, with no hosted URL.
The same outfit drawn the same way (the same pieces in the same
colours, the same direction, ratio and image settings) is served from
a cache of the organization's earlier renders: it comes back at once
as a hosted imageUrl, and its unit of quota is refunded. Renders
made with a shopper's photo are never cached or stored. Read
imageData or imageUrl, whichever is present.
Metering
Each request consumes one unit of the looks render resource
(api.v2.agent.looks.render, named api.v2.agent.looks on plans not
yet moved to it), separate from the v1 outfit endpoint. A cached
render and a 502 (or any other 5xx) are refunded.
Request body
application/jsonrequiredFull item ids of the garments worn together; repeats count once. Every id must resolve to an active item in scope (see the 404). Two or more, or one dress or jumpsuit on its own, or one item completed by ownPiece or a house basic.
Optional. The look includes a garment of the shopper's own, described in customInstructions; one item from the catalogue is then enough for a look. Pass the look's ownPiece unchanged. Only slot is read; without a string slot it is ignored.
Optional. The store's house basics the look wears, by name, as on the look's basics. A name the store does not list is dropped, so nothing else can be added to the picture this way. A basic other than shoes lets one item make a look.
Optional. One piece tried on by itself (see POST /v2/agent/looks/piece). Takes exactly one itemId, of any kind. With userPhotoUrl that one garment is put on the shopper and the rest of what they are wearing in their photo is kept. Without a photo nothing is drawn, and the store's own photo of the piece comes back as imageUrl (the unit of quota is refunded), or a 422 when it has none.
Optional, with piece and userPhotoUrl. Where the product has a photo of a model wearing it head to toe, the rest of what the model wears with it goes on the shopper too, in place of their own clothes (never anything from the model's head, neck or hands). Without such a photo the piece is drawn alone, as piece describes. The answer's visualization.asWorn says which it was.
Optional. The colour each piece is shown in, keyed by item id, as the product's colour variants name it (Teal, Black). Only that colour's photos are used for the piece. Without one, the piece is shown in the colour of its lead photo. A name the product does not sell is ignored.
Name of the look, used in the render prompt. Defaults to Look.
Datasets to resolve the items in. Omit or send [] for every active dataset. Must be an array of strings when present.
The shopper's own photo, to style the look onto them instead of a stock model. A base64 data: URL of a JPEG, PNG or WebP image, at most 3 MB decoded, never a web URL. The render keeps the photo's shape. Stylor uses it for this request only and stores neither the photo nor the render made from it, so keep both in the shopper's browser if you need them again. Refused when the store has switched try-on off (the looks event's tryOn is false).
Render preferences. Other keys are accepted and ignored.
Output aspect ratio. Any other value is refused with 422. Omitted, 3:4. With userPhotoUrl the photo's own shape is kept.
3:41:1Whether the look is drawn on a woman or a man. Without it, the department the items are filed under when they all agree.
womensmensFree-text direction for anything the product photos cannot convey. Pass the value from the look unchanged; omit or null when there is none.
Your identifier for the shopper's visit, for analytics only.
Visit metadata for analytics.
Option 1: Session
Where the shopper is talking to the agent. Defaults to widget when omitted.
Which agent version your client is built against. Use v2.
How your client persists the visit id — for example memory, session or local. Defaults to memory.
The shopper's IANA time zone.
The shopper's BCP 47 locale.
A coarse device class, typically mobile or desktop.
Option 2: null
Response
Response headers
X-RateLimit-ResourceThe quota resource this endpoint is metered against: api.v2.agent.chat
for the chat endpoint, api.v2.agent.looks.render for the looks
endpoint (api.v2.agent.looks on a plan not yet moved to it),
api.v2.agent.match for shop the look, api.v2.agent.looks.complete
for complete the look and api.v2.agent.pose for the pose endpoint.
These are separate from the v1 resources, so Agent API usage never
draws down a v1 allowance.
X-RateLimit-Quota-LimitRequests allowed in the current billing period, or unlimited.
X-RateLimit-Quota-RemainingRequests left in the current billing period, or unlimited.
X-RateLimit-Quota-ResetUnix epoch seconds at which the billing period resets.
X-RateLimit-RPM-LimitRequests allowed per minute for this resource.
X-RateLimit-RPM-RemainingRequests left in the current one-minute window.
X-RateLimit-RPM-ResetUnix epoch seconds at which the one-minute window resets.
One of three shapes. A new render carries imageData. A render served from the organization's cache carries imageUrl alone. A look of one dress or jumpsuit with no userPhotoUrl, no customInstructions and no house basic other than shoes is shown in the store's own photo of it on a model instead, when there is one, and carries imageUrl and source (product photo); it is rendered like any other look when the store has no photo of it worn.
A new render as a data:<mime>;base64,… URI, usable directly as an <img src>. Typically image/png.
A hosted image, usable directly as an <img src>. The cached render, or the product's own model photo for a one-piece look.
Present only when imageUrl is the product's own model photo.
product photoErrors
34Every error is JSON with a single error string unless noted. Match on the status code; the message is for humans.
Request body must be valid JSON.The body could not be parsed as JSON.
Request body must be a JSON object.The body is empty, or is valid JSON that is not an object (for example an array).
This store does not offer seeing looks on your own photo.userPhotoUrl was sent and a store the pieces come from has switched off try-on (the Styling tab's "See it on you").
No active datasets found for this organization. Activate one via the dashboard (Dataset → Settings) or through the REST API before proceeding.datasetIds was omitted and the organization has datasets, but none is active.
All requested datasets are archived. Reactivate at least one via the dashboard or REST API.Every dataset in datasetIds is archived.
No datasets found for this organization. Create one via the dashboard or REST API, or pass datasetIds to use draft/archived datasets before proceeding.The organization has no datasets at all.
These items could not be found: <ids>.One or more of itemIds did not match an active item in the resolved datasets. The unmatched ids are listed, comma-separated. Check that you sent full item ids from this organization's catalogue, and the same datasetIds the agent searched.
A look needs at least one itemId.itemIds is missing, not an array, or has no non-empty string in it.
A look can hold at most 6 items.itemIds has more than six distinct ids.
datasetIds must be an array of strings.datasetIds was sent and is not an array of strings (for example null).
preferences.aspectRatio must be one of: 3:4, 1:1.preferences.aspectRatio was sent and is not 3:4 or 1:1.
userPhotoUrl must be a base64 data: URL of a JPEG, PNG or WebP image. Shopper photos are never fetched from a URL or stored.userPhotoUrl is a web URL, a storage key, or any other type of image. Send the photo's bytes inline.
userPhotoUrl can be at most 3 MB.The photo in userPhotoUrl is larger than 3 MB once decoded. Downscale it in the browser first; around 1024px on the long edge is plenty.
Invalid datasetIds for this organization: <ids>One or more of datasetIds does not belong to the organization. The offending ids are listed, comma-separated.
piece takes exactly one itemId.piece is true and itemIds does not name exactly one item.
piece needs userPhotoUrl: one piece is drawn only on the shopper's own photo.piece is true, no userPhotoUrl was sent, and the store has no photo of the piece worn.
A look needs at least two items, or one dress or jumpsuit.itemIds names one item that is not a dress or jumpsuit, and neither ownPiece nor a house basic other than shoes completes it.
Could not generate this look.The image model returned no image or failed, including when none of the product images could be fetched. Retrying usually succeeds.
curl -X POST "https://stylor.ai/api/v2/agent/looks" \
-H "Authorization: Bearer $STYLOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"label": "Garden wedding",
"itemIds": [
"8f2c1a9e-4b7d-4c1e-9a3f-2d6b7e5c1a90",
"1b7e33c0-9a2d-4f8e-b5c6-7d8e9f0a1b2c",
"c4d5e6f7-0a1b-4c2d-8e9f-0a1b2c3d4e5f"
],
"customInstructions": "Shirt untucked with the top button open; outdoor daylight setting.",
"sessionId": "3b0d4a1e-6f52-4b8a-9d3c-7e2f1a0b9c8d",
"session": {
"surface": "widget",
"agentVersion": "v2"
}
}'{
"visualization": {
"imageData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAKqCAYAAAB..."
}
}