Skip to content

DOCS

Stream protocol

One POST, one SSE response, a closed event list. Frontend vs backend tool.call targets.

Framing

Each event is an SSE line data: {json} followed by a blank line. The stream ends with data: [DONE]. Client Accept in sveda mode is application/vnd.sveda.stream+json. Response Content-Type is text/event-stream. The runtime sets x-sveda-protocol-version: 1.0.

POST /sveda/stream
Accept: application/vnd.sveda.stream+json
Content-Type: application/json
x-sveda-embed-token: sveda_embed_…

Content-Type: text/event-stream
x-sveda-protocol-version: 1.0
data: {"type":"message.start","chatId":"chat_1"}

data: {"type":"text.delta","delta":"Hello","chatId":"chat_1"}

data: {"type":"message.end","finishReason":"stop","chatId":"chat_1"}

data: [DONE]

Event list

Closed set from StreamEvent. Do not invent aliases.

message.start

Turn opened. Optional chatId, messageId, timestamp.

text.delta

Assistant token. Field delta.

reasoning.delta

Reasoning token. Field delta.

tool.call

toolCallId, toolName, input, target backend | frontend.

tool.result

toolCallId, toolName, output; optional renderHint, renderData.

tool.progress

Optional phase plus tasks[{ id, label, status, detail }].

context.usage

usedTokens, maxTokens, percent.

chat.title

Generated title for the chat.

max_steps

maxSteps, canContinue. Client may continueAfterMaxSteps().

message.end

Optional finishReason and usage. Turn closed.

error

code and message.

tool.call target

target is backend or frontend. Backend tools run in sveda-server (builtins and host MCP). Frontend tools run in the browser via SvedaToolRegistryMCP and tools.

data: {"type":"tool.call","toolCallId":"call_1","toolName":"search_code","target":"backend","input":{"query":"SvedaClient"}}

data: {"type":"tool.call","toolCallId":"call_2","toolName":"get_selection","target":"frontend","input":{}}

Tools ride the same stream.

search_code, frontend register, host MCP — one event list, two targets.

MCP and tools