Interface: StreamEvent
@providerprotocol/ai / @providerprotocol/ai / StreamEvent
Interface: StreamEvent
Section titled “Interface: StreamEvent”Defined in: src/types/stream.ts:147
A single streaming event from the LLM.
Events are emitted in order as the model generates output, allowing for real-time display of responses.
Example
Section titled “Example”import { StreamEventType } from 'upp';
for await (const event of stream) { if (event.type === StreamEventType.TextDelta) { process.stdout.write(event.delta.text ?? ''); } else if (event.type === StreamEventType.ToolCallDelta) { console.log('Tool:', event.delta.toolName); }}Extended by
Section titled “Extended by”Properties
Section titled “Properties”delta:
EventDelta
Defined in: src/types/stream.ts:163
Event-specific data payload
index:
number
Defined in: src/types/stream.ts:160
Index of the content block this event belongs to
type:
string&Record<never,never> |StreamEventType
Defined in: src/types/stream.ts:157
Event type discriminator.
Uses StreamEventType | (string & Record<never, never>) to allow custom
event types (like ‘flow_stage’) while preserving autocomplete for known types.
The (string & Record<never, never>) pattern is a TypeScript idiom that
widens the type to accept any string without losing the literal type union
in IDE autocomplete suggestions.