Interface: StreamResult
@providerprotocol/ai / @providerprotocol/ai / StreamResult
Interface: StreamResult<TData>
Section titled “Interface: StreamResult<TData>”Defined in: src/types/stream.ts:196
Stream result - an async iterable that also provides the final turn.
Allows consuming streaming events while also awaiting the complete
Turn result after streaming finishes. Implements PromiseLike<Turn>
for direct awaiting with automatic stream consumption.
Example
Section titled “Example”import { StreamEventType } from 'upp';
const stream = instance.stream('Tell me a story');
// Option 1: Consume streaming events manuallyfor await (const event of stream) { if (event.type === StreamEventType.TextDelta) { process.stdout.write(event.delta.text ?? ''); }}const turn = await stream.turn;
// Option 2: Just await the turn (auto-drains the stream)const turn = await instance.stream('Tell me a story');
// Option 3: Fire-and-forget with callbackinstance.stream('Tell me a story').then(turn => saveToDB(turn));Extends
Section titled “Extends”AsyncIterable<StreamEvent>.PromiseLike<Turn<TData>>
Type Parameters
Section titled “Type Parameters”TData = unknown
Type of the structured output data
Properties
Section titled “Properties”
readonlyturn:Promise<Turn<TData>>
Defined in: src/types/stream.ts:204
Promise that resolves to the complete Turn after streaming finishes. Rejects if the stream is aborted or terminated early.
Accessing turn auto-drains the stream if it has not been iterated yet.
Methods
Section titled “Methods”[asyncIterator]()
Section titled “[asyncIterator]()”[asyncIterator]():
AsyncIterator<StreamEvent,any,any>
Defined in: node_modules/typescript/lib/lib.es2018.asynciterable.d.ts:38
Returns
Section titled “Returns”AsyncIterator<StreamEvent, any, any>
Inherited from
Section titled “Inherited from”AsyncIterable.[asyncIterator]
abort()
Section titled “abort()”abort():
void
Defined in: src/types/stream.ts:210
Aborts the stream, stopping further events and cancelling the request. This will cause StreamResult.turn to reject.
Returns
Section titled “Returns”void
then()
Section titled “then()”then<
TResult1,TResult2>(onfulfilled?,onrejected?):PromiseLike<TResult1|TResult2>
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1544
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
Section titled “Type Parameters”TResult1
Section titled “TResult1”TResult1 = Turn<TData>
TResult2
Section titled “TResult2”TResult2 = never
Parameters
Section titled “Parameters”onfulfilled?
Section titled “onfulfilled?”The callback to execute when the Promise is resolved.
(value) => TResult1 | PromiseLike<TResult1> | null
onrejected?
Section titled “onrejected?”The callback to execute when the Promise is rejected.
(reason) => TResult2 | PromiseLike<TResult2> | null
Returns
Section titled “Returns”PromiseLike<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
Inherited from
Section titled “Inherited from”PromiseLike.then