AI
5 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.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.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.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.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-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.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/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.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]}'