Stream Chat with Lexi
Lexi AI
Stream Chat with Lexi
Send a message to Lexi and receive the response as a Server-Sent Events stream
POST
Stream Chat with Lexi
Request
This is the streaming counterpart toPOST /v1/lexi/chat. The response is a text/event-stream that emits incremental events as Lexi reasons through the prompt and uses tools. Because the request is a POST, you must use a fetch-based SSE client - the browser’s EventSource only supports GET.
Headers
Optional UUID to deduplicate retries within 24 hours. Credits are charged only on the first successful stream.
Body Parameters
User message to send to Lexi. Maximum 12,000 characters.
Optional conversation UUID. When omitted, a new conversation is created and its ID is emitted in the first
text event’s conversation_id metadata.Optional page / entity context:
contact_id, deal_id, matter_id, company_id, page.When
false, Lexi will not invoke any CRM tools and will respond purely from the conversation context.Event Types
| Event | Purpose |
|---|---|
thinking | Intermediate reasoning step. Payload: data: {"text": "..."}. Safe to ignore if not rendering a progress UI. |
tool_step | Lexi is about to invoke or has completed a CRM tool. Payload: data: {"tool": "...", "status": "started" or "completed", "summary": "..."}. |
text | Incremental assistant text. Payload: data: {"delta": "...", "conversation_id": "..."}. Concatenate delta values to build the final response. |
done | Final event with usage metadata. Payload: data: {"credits_remaining": 4840, "message_id": "msg_01HY1"}. |
data: [DONE] followed by a newline, consistent with the OpenAI SSE convention.
Response Format
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID headers on the initial HTTP response.
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing message, or prompt exceeds size limit |
| 401 | invalid_key | Invalid or expired API key |
| 402 | insufficient_credits | Workspace credit balance is exhausted |
| 403 | insufficient_permissions | Missing write:ai permission |
| 404 | conversation_not_found | Supplied conversation_id does not exist |
| 429 | rate_limited | Rate limit exceeded |
event: error in the SSE stream when they occur after the HTTP headers have been sent, with the same code / message payload as JSON responses. Clients should therefore handle both HTTP-level and in-stream error events.