chat.v1
Status: v1. A published shape is frozen by spec.md section 20.1.
Capability key: chat
Route: POST /chat
Parts in
| kind | role | required | meaning |
| text | system | no | the system instruction. At most one. Must come first. |
| text | user | yes, one or more | a user turn. |
| text | assistant | no | a previous assistant turn. |
| text | tool | no | a tool result. The role field of the text part names the tool call. |
| image | user | no | a visual input. The model must declare image in its parts. |
| audio | user | no | a speech input. The model must declare audio in its parts. |
| json | tools | no | {"tools": [{"name", "description", "parameters"}]}. |
| json | response_format | no | {"type": "text"} or {"type": "json_object"}. |
Parameters
The plugin validates these. A parameter that is not in this table is ignored,
not an error (R26). A default of catalogue means the model entry in the
catalogue gives the value.
| name | type | default | meaning |
max_tokens | uint | catalogue | the output limit |
temperature | float | catalogue | sampling temperature |
top_p | float | catalogue | nucleus sampling |
top_k | uint | catalogue | top-k sampling. 0 disables it. |
stop | string array | catalogue | stop sequences |
seed | uint | none | a fixed seed for a repeatable job |
tool_choice | string | auto | auto, none, or the name of one tool |
logprobs | bool | false | emit tokens events as well as text |
Channels out
| channel | mime | payload |
| text | text/plain; charset=utf-8 | one UTF-8 fragment of the answer |
| tokens | application/cbor | an array of {id: uint, text: bstr, logprob: float / null} |
| decision | application/json | one tool call: {call_id, name, arguments} |
| progress | application/json | {stage, pct} during prefill or a batch |
| key | type | meaning |
finish_reason | string | stop, length, tool_calls, or content_filter |
model | string | the served name that ran the job |
finish_reason is required when outcome is completed. It is absent when the
outcome is cancelled or expired.
Request
POST /chat
{
"model": "example",
"input": [
{"kind": "text", "role": "system", "text": "You answer in one line."},
{"kind": "text", "role": "user", "text": "What is a ledger?"},
{"kind": "image", "role": "user", "mime": "image/png", "blob": "<sha256>"}
],
"params": {"max_tokens": 128, "temperature": 0.0},
"stream": true
}
Response, no stream
{"job": "019...", "outcome": "completed",
"text": "A record of reserved bytes for each device.",
"usage": {"tokens_in": 9, "tokens_out": 12},
"meta": {"finish_reason": "stop", "model": "example"}}
Stream
event ch=progress {"stage": "prefill", "pct": 0.4}
event ch=text "A record of"
event ch=text " reserved bytes"
event ch=decision {"call_id": "c1", "name": "lookup", "arguments": {"term": "ledger"}}
done outcome=completed meta={"finish_reason": "tool_calls"}
Rules
- At least one
text part with role user is required. A request with no user
turn is invalid_part.
- The plugin applies the chat template and the stop set. The core and the
adapters never do. The template name comes from the catalogue.
- One
text event is a whole UTF-8 sequence. A plugin never splits a code
point across two events.
- A tool call is one
decision event per call. The arguments are a JSON
object, not a string. call_id is chosen by the plugin and is unique in the
job.
finish_reason is exactly one value. A job that reaches max_tokens reports
length, not stop.
tokens events are opt-in. A plugin that cannot give logprobs still accepts
logprobs = true and emits its best token split, or omits the channel.
- No event follows a
cancel. The terminal frame is done with
outcome = cancelled.
- The plugin emits bytes and JSON only. Framing belongs to the core and to the
web.