FLAM

Chat

6 Chat routes on the FLAM API: One turn of the loop; Undo, redo, and any direct edit; Prepare private chat context.

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/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, and sessionId keeps another open topic from receiving it). Free — a turn never spends tokens.

Request bodyapplication/json (required)

FieldTypeRequiredNotes
messagestringyes
draftobjectno
historyobject[]no
screenstringno
turnIdstringno
sessionIdstringnoExisting conversation. Omit to create one atomically with the turn.
{
  "message": "string",
  "draft": {},
  "history": [
    {
      "role": "director",
      "text": "string"
    }
  ],
  "screen": "string",
  "turnId": "string",
  "sessionId": "string"
}

Responses

StatusMeaning
200The turn
400BAD_BODY / BAD_MESSAGE / BAD_DRAFT
401No valid session
502AI_UNAVAILABLE
503AI_NOT_CONFIGURED / AI_GATEWAY_NEEDS_BILLING

200 returns:

{
  "text": "string",
  "applied": [
    {}
  ],
  "mirror": {},
  "turnId": "string",
  "sessionId": "string",
  "persisted": true
}

Call it

curl -X POST "https://api-staging.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","sessionId":"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 bodyapplication/json (required)

FieldTypeRequiredNotes
draftobjectno
mutationobjectyes
{
  "draft": {},
  "mutation": {}
}

Responses

StatusMeaning
200The new draft
400BAD_BODY / BAD_DRAFT / BAD_MUTATION
401No valid session
404ASSET_NOT_FOUND
422CANNOT_APPLY { reason }

200 returns:

{
  "draft": {},
  "applied": {}
}

Call it

curl -X POST "https://api-staging.flam.fashion/api/chat/apply" \
  -H "Authorization: Bearer $FLAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"draft":{},"mutation":{}}'

POST /api/chat/context/warm

Prepare private chat context

Starts a background refresh of the signed-in person's house and personal memory. It returns immediately and never exposes the cached memory to the browser.

Responses

StatusMeaning
202The background refresh started.
401No signed-in person.

202 returns:

{
  "warming": true
}

Call it

curl -X POST "https://api-staging.flam.fashion/api/chat/context/warm" \
  -H "Authorization: Bearer $FLAM_API_KEY"

GET /api/chat/sessions

List this director's recent conversations

Newest first, scoped to both the active house and actor.

Responses

StatusMeaning
200Recent open conversations
401No valid session

200 returns:

{
  "sessions": [
    {
      "id": "string",
      "title": "string",
      "createdAt": "2026-07-27T09:00:00.000Z",
      "lastTurnAt": "2026-07-27T09:00:00.000Z"
    }
  ]
}

Call it

curl -X GET "https://api-staging.flam.fashion/api/chat/sessions" \
  -H "Authorization: Bearer $FLAM_API_KEY"

POST /api/chat/sessions

Start a new conversation

Creates an empty actor-visible working context in the active house.

Request bodyapplication/json

FieldTypeRequiredNotes
titlestringno
{
  "title": "string"
}

Responses

StatusMeaning
201The new conversation
401No valid session

201 returns:

{
  "session": {
    "id": "string",
    "title": "string",
    "createdAt": "2026-07-27T09:00:00.000Z",
    "lastTurnAt": "2026-07-27T09:00:00.000Z"
  }
}

Call it

curl -X POST "https://api-staging.flam.fashion/api/chat/sessions" \
  -H "Authorization: Bearer $FLAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"string"}'

GET /api/chat/sessions/{id}/turns

Restore one conversation

Returns at most 200 exact UI turns, oldest first.

Parameters

InNameTypeRequiredNotes
pathidstringyes

Responses

StatusMeaning
200The persisted transcript
401No valid session
404CHAT_SESSION_NOT_FOUND

200 returns:

{
  "turns": [
    {}
  ]
}

Call it

curl -X GET "https://api-staging.flam.fashion/api/chat/sessions/{id}/turns" \
  -H "Authorization: Bearer $FLAM_API_KEY"