Skip to main content
A Canvas can receive a conversation in addition to its variables. The messages array carries that history: what the user said and what the assistant answered before, in order. Use it to build chat experiences on top of a Canvas, or to give the model context that does not fit a variable. messages is optional, and it works together with variables: the Canvas prompt is still rendered with the variables, and the messages are added to the conversation.

Message shape

Each message has a role and a content: Order matters. The array is the chronological flow of the conversation, so put the oldest message first. A typical history alternates user and assistant messages.
The answer comes back as usual in choices[0].message.content. To continue the conversation, append the assistant answer and the next user message to the array and call again: the API does not keep the conversation between calls.

Files and images in messages

Besides a string, content accepts a file reference with a file_url, in the same formats accepted by file variables:
HTTP body
Content can also be written as content parts, the format used when a run is recorded: a text part { "type": "text", "text": "…" } or an image part { "type": "image_url", "image_url": { "url": "…", "detail": "auto" | "high" | "low" } }.
Files sent in messages appear in the recorded run under input_content.files with used_at: "messages" and a name such as message-0, where the number is the position of the message in the array.
Both the messages and the variables of a run are kept in input_content and raw_input, so you can inspect exactly what was sent when you fetch or list runs.