Send a natural language message and receive a streamed response via Server-Sent Events (SSE).Documentation Index
Fetch the complete documentation index at: https://docs.trellis.sh/llms.txt
Use this file to discover all available pages before exploring further.
For a complete guide on handling responses, see the Chat Overview.Prefer real-time bidirectional communication? Use the WebSocket endpoint instead.
Bearer token obtained from the authenticate endpoint.
Set to
text/event-stream to receive SSE responses.The natural language message to send.
ID of an existing chat. Obtain one from Create Chat. Omitting this field returns
400 MISSING_CHAT_ID; passing an ID that doesn’t belong to the caller returns 404 CHAT_NOT_FOUND.ID of the database integration to query. Required for database queries.
Custom title for new chats. If omitted, a title is generated automatically.
AI model to use for this message. If omitted, the default model is used. See List Models for available values.
List of upload IDs to attach to this message. Upload files first via Upload Files, then reference their IDs here. Requires
chat_id to be set.ID of a saved query to execute deterministically. When provided, the saved query’s SQL is run directly instead of passing the message through the AI agent. Use List Saved Queries to retrieve query IDs.
Key-value pairs supplying runtime values for
{{param_name}} placeholders in the saved query’s SQL. Required when the saved query has a non-empty parameters array. Only applicable when saved_query_id is set.When
saved_query_id is provided, the AI agent is bypassed and the saved query’s SQL is executed directly against the connected database. The message field is still required but is used only for display in the chat history. Any {{param_name}} placeholders in the SQL must have corresponding entries in parameters — missing values will return a 400 error.Response
The response is a stream of Server-Sent Events. See Chat Overview for details on handling the stream.Event types
| Event | Data | Description |
|---|---|---|
chat_metadata | {"id": "chat_...", "user_message_id": "msg_..."} | Chat ID and persisted user message ID. Emitted at the start of every response. |
processing | {"status": "starting" | "thinking" | "analyzing" | "processing"} | AI processing status. starting is emitted within ~100ms of request receipt. |
visualization | Full chart or table payload | A chart or table was generated. See Visualizations. |
text_delta | {"content": "..."} | An incremental chunk of the final assistant text, streamed as the model generates it. Multiple frames arrive per turn. Concatenate content values in order to build the response. |
message | {"content": "...", "id": "msg_..."} | The final response. Always carries the authoritative full content plus the persisted message id. Safe to overwrite any streaming buffer with content on receipt. |
error | {"error": "...", "code": "...", "retryable": boolean, "debug_id": "...", "error_type": "..."} | An error occurred. See WebSocket → Error codes for the stable code enum and retry semantics. |
text_delta events let you render the response progressively — typical time-to-first-token is about 1 second vs. several seconds for the full answer. See Chat Overview → Streaming text deltas for the buffer-and-reconcile pattern.