AI
7 AI routes on the FLAM API: Depth map for the Lens Blur tool (1 token); Classify one piece — auto-name + wardrobe bucket (1 token); Find every garment.
Base URL https://api-staging.flam.fashion. Send Authorization: Bearer flam_sk_… on every call; a handful of routes are session-only and say so. How keys and roles work.
POST /api/toolkit/ai/depth
Depth map for the Lens Blur tool (1 token)
Depth Anything V2 on fal → a grayscale depth PNG url. The map is an INTERNAL input to the client-side depth-of-field; it is NOT captured as a library asset. Reserve → settle on 200 / release on any failure, so a failed call charges nothing.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
image | file | no | — |
Responses
| Status | Meaning |
|---|---|
200 | The depth map |
400 | IMAGE_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | No valid session |
402 | INSUFFICIENT_TOKENS { need, spendable } |
403 | A viewer may not spend the house's tokens |
413 | IMAGE_TOO_LARGE |
502 | DEPTH_FAILED |
503 | FAL_NOT_CONFIGURED |
200 returns:
{
"url": "string",
"spent": 0
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/depth" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string"}'POST /api/toolkit/ai/describe-item
Classify one piece — auto-name + wardrobe bucket (1 token)
The smart-upload classifier as a standalone lane. The same read runs in-process for /api/toolkit/assets/upload?classify=1. nameEn is capped at 40 characters and an unknown kind is clamped to "clothes" — the model can drift, the contract cannot.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
image | file | no | — |
Responses
| Status | Meaning |
|---|---|
200 | The label |
400 | IMAGE_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | No valid session |
402 | INSUFFICIENT_TOKENS / AI_NEEDS_BILLING |
403 | A viewer may not spend the house's tokens |
413 | IMAGE_TOO_LARGE |
502 | AI_BAD_OUTPUT / AI_FAILED |
503 | AI_NOT_CONFIGURED |
200 returns:
{
"ok": true,
"nameEn": "string",
"kind": "clothes"
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/describe-item" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string"}'POST /api/toolkit/ai/detect-items
Find every garment and accessory in a frame
Step 1 of 2 (detect then segment). Exhaustively detects each distinct garment, accessory and editable hair/face feature so a UI can draw tap targets. A rail of hanging clothes, a flat lay or a shop shelf is a normal input. Boxes are [ymin, xmin, ymax, xmax] normalized 0-1000 and are APPROXIMATE tap targets, not cutouts.
ORIENTATION: boxes are in the RAW stored pixel matrix; this lane does not apply a JPEG's EXIF Orientation flag and fal (behind /segment) does. Pass the returned label to /segment, or bake orientation before both calls. Flat 1 token, refunded on any failure.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
image | file | yes | — |
Responses
| Status | Meaning |
|---|---|
200 | Detected items |
400 | IMAGE_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | Unauthorized |
402 | INSUFFICIENT_TOKENS / AI_NEEDS_BILLING |
403 | A viewer may not spend the house's tokens |
413 | IMAGE_TOO_LARGE |
502 | AI_BAD_OUTPUT / AI_FAILED |
503 | AI_NOT_CONFIGURED |
200 returns:
{
"ok": true,
"items": [
{
"label": "string",
"box": [
0
]
}
]
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/detect-items" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string"}'POST /api/toolkit/ai/extract-build
Read a body out of a full-length photograph, in casting vocabulary
The dossier's second analyst pass. extract-character reads the FACE off a director's collage and is instructed to ignore the body; this reads the BODY off one full-length photograph and returns the five words a casting call sheet carries — height, build, presence, posture, hands — so a full-length reference sheet can be rendered from her proportions rather than the image model's default ones. Every field is hers to correct before a sheet is developed. NEVER INVENTS. A field it cannot see comes back empty, height is a casting word ("tall", "petite") and never a measurement a photograph cannot take, and the no-figure guard returns figureDetected=false with every field empty for a landscape, an object, a flat-lay garment or a head-and-shoulders portrait — a face crop is not a full-length photo and there is no proportion in one. Flat 1 token, refunded on any failure.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
image | file | yes | — |
Responses
| Status | Meaning |
|---|---|
200 | The five casting fields |
400 | IMAGE_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | Unauthorized |
402 | INSUFFICIENT_TOKENS / AI_NEEDS_BILLING |
403 | A viewer may not spend the house's tokens |
413 | IMAGE_TOO_LARGE |
502 | AI_BAD_OUTPUT / AI_FAILED |
503 | AI_NOT_CONFIGURED |
200 returns:
{
"ok": true,
"figureDetected": true,
"fields": {
"height": "string",
"build": "string",
"presence": "string",
"posture": "string",
"hands": "string"
}
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/extract-build" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string"}'POST /api/toolkit/ai/extract-character
Read a person out of a reference image (or a four-view collage)
Returns the five character-studio fields — age, skin, eyes, hair, extras — so a director can review WHO the house just cast before any frame is developed. A FLAM house model is a collage of several views of one person; the engine reads across all the panels and answers once. No-face guard: a landscape, an object or a garment shot returns faceDetected=false with every field empty. It never invents a person, and extras stays empty unless a real identifying mark is visible. Flat 1 token, refunded on any failure.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
image | file | yes | — |
Responses
| Status | Meaning |
|---|---|
200 | The five fields |
400 | IMAGE_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | Unauthorized |
402 | INSUFFICIENT_TOKENS / AI_NEEDS_BILLING |
403 | A viewer may not spend the house's tokens |
413 | IMAGE_TOO_LARGE |
502 | AI_BAD_OUTPUT / AI_FAILED |
503 | AI_NOT_CONFIGURED |
200 returns:
{
"ok": true,
"faceDetected": true,
"fields": {
"age": "string",
"skin": "string",
"eyes": "string",
"hair": "string",
"extras": "string"
}
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/extract-character" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string"}'POST /api/toolkit/ai/preflight
Pre-flight — what will go wrong, before you spend (free)
The judge, pointed backwards. Every other quality check in this API runs after the money is gone; this one runs on the references you are about to spend on and predicts what will go wrong in the generated result — three photos lit differently mean the frames will not match each other, and you find that out before the develop rather than after it.
WHAT IT ASKS DEPENDS ON WHAT YOU SENT. With no lens it asks the GARMENT questions only — light, colour, crop, shadow, background, size, hidden parts. It never asks whether a set is one person, because a rail of clothes has no answer to that and a finding you cannot act on is the same as a wrong one. Send lens to ask a narrower or a different question; a casting look is where the sentences about a face come from.
FREE, on purpose and by construction: a check that saves you money must not cost you money. Nothing in this path reserves against the ledger.
The vocabulary is CLOSED and the sentences are ours. The model returns a code and 1-based image indices; says (the consequence) and fix (what we will do about it) are looked up server-side, so an unknown code is dropped rather than surfaced with no sentence.
An empty findings array is the correct and common answer — a pre-flight that always finds something is one you learn to click past. clear is exactly findings.length === 0.
Capped at six images: a collage is three to six references, and past that the answer stops being actionable.
Request body — multipart/form-data (required)
| Field | Type | Required | Notes |
|---|---|---|---|
images | file[] | no | — |
Responses
| Status | Meaning |
|---|---|
200 | What will go wrong, or nothing |
400 | IMAGES_REQUIRED / EMPTY_IMAGE / BAD_FORM |
401 | No valid session |
413 | IMAGE_TOO_LARGE |
502 | AI_BAD_OUTPUT / AI_FAILED |
503 | AI_NOT_CONFIGURED |
200 returns:
{
"ok": true,
"clear": true,
"cleared": [
"string"
],
"remaining": [
"string"
],
"findings": [
{
"code": "light-mismatch",
"images": [
0
],
"says": "string",
"fix": "string",
"by": "house",
"sure": true
}
]
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/preflight" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrls":["string"],"lens":["string"],"clearing":["string"]}'POST /api/toolkit/ai/segment
A clean cutout of the ONE item that was tapped
Step 2 of 2 (detect then segment). SAM 3 on fal, prompted by the detect-items label (orientation-immune — prefer it), a box [x0,y0,x1,y1] in PIXELS of the EXIF-APPLIED frame, or a point [x,y]. At least one target is required. What comes back is an RGBA CUTOUT, not a white-on-black binary mask. It is an internal compositing input and is never captured as a library asset. Flat 1 token, refunded on failure.
Request body — application/json (required)
| Field | Type | Required | Notes |
|---|---|---|---|
imageUrl | string | yes | — |
label | string | no | — |
box | number[] | no | — |
point | number[] | no | — |
{
"imageUrl": "string",
"label": "string",
"box": [
0
],
"point": [
0
]
}Responses
| Status | Meaning |
|---|---|
200 | The cutout |
400 | BAD_JSON / IMAGE_REQUIRED / TARGET_REQUIRED |
401 | Unauthorized |
402 | INSUFFICIENT_TOKENS |
403 | A viewer may not spend the house's tokens |
502 | SEGMENT_FAILED |
503 | FAL_NOT_CONFIGURED |
200 returns:
{
"url": "string",
"bbox": [
0
],
"spent": 0
}Call it
curl -X POST "https://api-staging.flam.fashion/api/toolkit/ai/segment" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"imageUrl":"string","label":"string","box":[0],"point":[0]}'Brand
7 Brand routes on the FLAM API: The house's extracted visual DNA; Correct the extracted DNA, or switch the injection off; Read the house's visual DNA off.
Toolkit
4 Toolkit routes on the FLAM API: Remove background (sync, fal birefnet); Another take — N frames back in, her sentence on each; Curated content items.