Prepare Chat
Prepare a chat turn: load and merge prior history, resolve intent, build system/context messages, and run any server-side action. The client then streams the model call using the returned messages.
Authentication: Required — Bearer token.
Feature gate: Requires a configured LoyalStream/AI connector — otherwise 403 ai_sdk_unavailable.
Request body (all optional unless noted):
client_id— Conversation/client id used to load and merge prior historymessages— Array of prior{ role, content }turns (last 20 kept)message— The current user message; appended as a user turn if not already lastpage_context— Context about the page the user is on
Response: data whose shape depends on data.type:
ready—system_messages,base_messages,model,intent,action_context,conversation_id,safe_intent,content_cardslimit_reached/denied/action_result— carrydeny_messageorassistant_contentplusconversation_id,base_messages, etc. (auto-persisted server-side)
Errors:
403—ai_sdk_unavailable422—{ error: { message } }on a raised error
Authentication
AuthorizationBearer
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
This endpoint expects an object.
client_id
message
messages
page_context
Response
OK