Skip to main content
SSE Behavior:
  • Supports automatic reconnection with Last-Event-ID header
  • When the client reconnects, the server resumes from the last received event
  • Stream terminates with [DONE] message

Stream Event Types

The stream returns TextStreamPartWrapper events with a discriminated type field. These events are compatible with the Vercel AI SDK format.
Event TypeDescription
startMarks the beginning of the streaming session
start-stepMarks the beginning of an agentic step
text-startMarks the beginning of a text block
text-deltaIncremental text content
text-endMarks the end of a text block
reasoning-startMarks the beginning of reasoning/thinking content
reasoning-deltaIncremental reasoning content
reasoning-endMarks the end of reasoning content
tool-input-startMarks the beginning of tool input streaming
tool-input-deltaIncremental tool input (JSON streaming)
tool-input-endMarks the end of tool input
tool-callComplete tool call with parsed input
tool-resultTool execution result
finish-stepMarks the end of an agentic step
finishMarks the end of the streaming session
errorError during streaming

text-delta

Incremental text content from the agent.
interface TextDeltaPart {
  type: 'text-delta';
  id: string;          // Text block ID
  text: string;        // Text delta content
  metadata?: {
    parentToolUseId?: string;  // For subagent context
  };
}

tool-call

Complete tool call with parsed input arguments.
interface ToolCallPart {
  type: 'tool-call';
  toolCallId: string;              // Unique tool call ID
  toolName: string;                // Name of the tool
  input: Record<string, unknown>;  // Parsed input arguments
  metadata?: {
    parentToolUseId?: string;
  };
}

tool-result

Tool execution result.
interface ToolResultPart {
  type: 'tool-result';
  toolCallId: string;   // Tool call ID
  toolName: string;     // Name of the tool
  output?: unknown;     // Tool output
  metadata?: {
    parentToolUseId?: string;
  };
}

finish

Marks the end of the streaming session.
interface FinishPart {
  type: 'finish';
  finishReason: 'stop' | 'tool-calls' | 'length' | 'content-filter' | 'error' | 'other';
  totalUsage: {
    inputTokens: number;
    outputTokens: number;
    totalTokens?: number;
  };
  metadata?: {
    cost?: number;
    durationMs?: number;
  };
}

error

Error during streaming.
interface StreamErrorPart {
  type: 'error';
  error: string;         // Error message
  rawContent?: unknown;  // Original content that caused the error
}
These event types are designed to be compatible with the Vercel AI SDK streaming format, making it easy to integrate with AI SDK-based applications.