AI SDK v6 Protocol
The AI SDK v6 adapter translates Awaken’s internal AgentEvent stream into the Vercel AI SDK v6 UI Message Stream format. This allows any AI SDK-compatible frontend (useChat, useAssistant) to consume agent output without custom parsing or a custom frontend transport adapter. Awaken-specific data-* parts are optional metadata for richer consoles; ordinary chat UIs may ignore them.
Endpoint
Section titled “Endpoint”POST /v1/ai-sdk/chatRequest Body
Section titled “Request Body”{ "messages": [ { "id": "msg-1", "role": "user", "parts": [{ "type": "text", "text": "Hello" }] } ], "threadId": "optional-thread-id", "agentId": "optional-agent-id"}| Field | Type | Required | Description |
|---|---|---|---|
messages | UIMessage[] | yes | AI SDK v6 UI messages. text and file parts become runtime content; tool/data/source parts are UI state and are not sent to the model. |
threadId | string | no | Existing thread to continue. Omit to create a new thread. |
agentId | string | no | Target agent. Uses the default agent when omitted. |
file parts may use hosted URLs or Data URLs. Images, audio, video, PDFs, and
text-like documents are converted to runtime ContentBlocks. The selected
model must advertise compatible input modalities when modalities are enforced.
Response
Section titled “Response”SSE stream (text/event-stream). Each line is a JSON-encoded UIStreamEvent.
Auxiliary Routes
Section titled “Auxiliary Routes”| Route | Method | Description |
|---|---|---|
/v1/ai-sdk/threads/:thread_id/runs | POST | Start a thread-scoped run. |
/v1/ai-sdk/agents/:agent_id/runs | POST | Start an agent-scoped run. |
/v1/ai-sdk/agent-previews/runs | POST | Run a draft AgentSpec against the current registries without persisting it. |
/v1/ai-sdk/chat/:thread_id/stream | GET | Reconnect to an active SSE stream by thread ID. |
/v1/ai-sdk/threads/:thread_id/stream | GET | Alias for thread stream reconnect. |
/v1/ai-sdk/threads/:thread_id/replay | GET | Replay durable protocol frames for a thread. |
/v1/ai-sdk/chat/:thread_id/replay | GET | Alias for durable protocol replay. |
/v1/ai-sdk/threads/:thread_id/messages | GET | Retrieve thread message history. |
/v1/ai-sdk/threads/:thread_id/cancel | POST | Cancel the active or queued run on a thread. |
/v1/ai-sdk/threads/:thread_id/interrupt | POST | Interrupt a thread, supersede queued work, and cancel the active run. |
Replay routes require a configured ProtocolReplayLog. They accept
?cursor= or Last-Event-ID, plus ?limit= (default 100, max 500), and
return SSE frames with the protocol replay cursor as the SSE id. Missing
replay storage returns 503; malformed cursors return 400; expired cursors
return 410 Gone.
Event Mapping
Section titled “Event Mapping”The AiSdkEncoder is a stateful transcoder that converts AgentEvent variants into UIStreamEvent variants. It tracks open text blocks and reasoning blocks across tool-call boundaries.
| AgentEvent | UIStreamEvent(s) |
|---|---|
RunStart | MessageStart + Data("run-info", ...) |
TextDelta | TextStart (if block not open) + TextDelta |
ReasoningDelta | ReasoningStart (if block not open) + ReasoningDelta |
ReasoningEncryptedValue | ReasoningStart (if not open) + ReasoningDelta |
ToolCallStart | Close open text/reasoning blocks, then ToolCallStart |
ToolCallDelta | ToolCallDelta |
ToolCallDone | ToolCallEnd |
StepStart | (no direct mapping) |
StepEnd | (no direct mapping) |
InferenceComplete | Data("inference-complete", ...) |
MessagesSnapshot | Data("messages-snapshot", ...) |
StateSnapshot | Data("state-snapshot", ...) |
StateDelta | Data("state-delta", ...) |
ActivitySnapshot | Data("activity-snapshot", ...) |
ActivityDelta | Data("activity-delta", ...) |
RunFinish | Close open blocks, Data("finish", ...), Finish |
UIStreamEvent Types
Section titled “UIStreamEvent Types”The wire format uses the type field as a discriminant, serialized in kebab-case:
start— message lifecycle start, carries optionalmessageIdandmessageMetadatatext-start,text-delta,text-end— text block lifecycle with content IDreasoning-start,reasoning-delta,reasoning-end— reasoning block lifecycletool-call-start,tool-call-delta,tool-call-end— tool call lifecycledata— arbitrary named data events (state snapshots, activity, inference metadata)finish— terminal event with finish reason and usage summary
Text Block Lifecycle
Section titled “Text Block Lifecycle”The encoder automatically manages text block open/close boundaries:
- First
TextDeltaopens a text block (TextStart). - Subsequent deltas append to the open block.
- When a
ToolCallStartarrives, the encoder closes any open text or reasoning block before emitting tool events. - After tool execution completes, new text deltas open a fresh block with an incremented ID.
This ensures the frontend receives well-formed block boundaries even though the runtime emits flat delta events.
Related
Section titled “Related”- Events — full
AgentEventenum - HTTP API — server configuration
- Integrate AI SDK Frontend — frontend integration guide