Skip to main content
Send a natural language message and receive a streamed response via Server-Sent Events (SSE).
For a complete guide on handling SSE responses, see the Chat Overview.
Authorization
string
required
Bearer token obtained from the authenticate endpoint.
Accept
string
Set to text/event-stream to receive SSE responses.
message
string
required
The natural language message to send.
chat_id
string
ID of an existing chat to continue the conversation. Omit to create a new chat.
integration_id
string
ID of the database integration to query. Required for database queries.
title
string
Custom title for new chats. If omitted, a title is generated automatically.

Response

The response is a stream of Server-Sent Events. See Chat Overview for details on handling the stream.

Event types

EventDataDescription
chat_metadata{"id": "chat_..."}New chat ID (only for new chats)
processing{"status": "thinking"}AI is processing the request
visualization{"id": "viz_..."}A chart was generated
message{"content": "...", "id": "msg_..."}The final response
error{"error": "..."}An error occurred
curl -X POST https://api.trellis.sh/v1/chats \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "message": "How many orders were placed last month?",
    "integration_id": "550e8400-e29b-41d4-a716-446655440000"
  }'
event: chat_metadata
data: {"id": "chat_abc123"}

event: processing
data: {"status": "thinking"}

event: processing
data: {"status": "analyzing"}

event: message
data: {"content": "There were 1,523 orders placed last month (December 2024).", "id": "msg_xyz789"}