Chat
2 Chat routes on the FLAM API: One turn of the loop; Undo, redo, and any direct edit.
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/chat
One turn of the loop
The house reads the message against the current draft and answers with what it said plus the mutations it applied. Every applied mutation is ALSO pushed over the job socket the moment it lands (turnId is echoed so the tab that asked does not render it twice). Free — a turn never spends tokens.
Request body — application/json (required)
| Field | Type | Required | Notes |
|---|---|---|---|
message | string | yes | — |
draft | object | no | — |
history | object[] | no | — |
screen | string | no | — |
turnId | string | no | — |
{
"message": "string",
"draft": {},
"history": [
{
"role": "director",
"text": "string"
}
],
"screen": "string",
"turnId": "string"
}Responses
| Status | Meaning |
|---|---|
200 | The turn |
400 | BAD_BODY / BAD_MESSAGE / BAD_DRAFT |
401 | No valid session |
502 | AI_UNAVAILABLE |
503 | AI_NOT_CONFIGURED / AI_GATEWAY_NEEDS_BILLING |
200 returns:
{
"text": "string",
"applied": [
{}
],
"mirror": {},
"turnId": "string"
}Call it
curl -X POST "https://api.flam.fashion/api/chat" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message":"string","draft":{},"history":[{"role":"director","text":"string"}],"screen":"string","turnId":"string"}'POST /api/chat/apply
Undo, redo, and any direct edit
ONE door for both directions of the walk — undo posts the inverse, redo posts the mutation. Free by definition: a mutation never spends. A selection can only ever name pieces this house holds.
Request body — application/json (required)
| Field | Type | Required | Notes |
|---|---|---|---|
draft | object | no | — |
mutation | object | yes | — |
{
"draft": {},
"mutation": {}
}Responses
| Status | Meaning |
|---|---|
200 | The new draft |
400 | BAD_BODY / BAD_DRAFT / BAD_MUTATION |
401 | No valid session |
404 | ASSET_NOT_FOUND |
422 | CANNOT_APPLY { reason } |
200 returns:
{
"draft": {},
"applied": {}
}Call it
curl -X POST "https://api.flam.fashion/api/chat/apply" \
-H "Authorization: Bearer $FLAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"draft":{},"mutation":{}}'