Response format

Multi-turn conversations

To continue a conversation, pass the previous turns in the turns[] array. Each turn is built from the request’s input and the response’s output/messages.

Building a turn

Once you have the result, take the task’s turn as a whole (it already contains input, output, messages and metadata) and put it into the turns[] of the next request.

request 1
{
  "assistant_id": 1,
  "input": [{ "type": "text", "text": "What is Laravel?" }]
}
request 2 — with history
{
  "assistant_id": 1,
  "input": [{ "type": "text", "text": "How does routing work?" }],
  "turns": [
    {
      "input":    [/* from response 1 */],
      "output":   [/* from response 1 */],
      "messages": [/* from response 1 — required */],
      "metadata": {/* from response 1 — optional */}
    }
  ]
}

Rules

Turn fieldPass it?
messagesRequired — it’s the model’s actual context.
outputYes — used for file context and by some tools.
inputYes.
metadataOptional — only the client needs it, to display the cost.

The order in turns[] is chronological, oldest turns first.

Common mistakes

SituationConsequence
messages: [] or missingThe model doesn’t see the history — the context is empty.
Only metadata passed, without messagesSame thing.
turns[] in reverse orderThe model sees the history backwards.
A very long historyYou may exceed the model’s context limit.
Native image models
An assistant message from a native image model contains the full base64 image data in messages. Passing such a turn in turns[] adds several MB to the request body. If you don’t need the history, you can leave that messages out.