Stream data in realtime from inside your tasks
metadata.stream. The following example uses the OpenAI SDK with stream: true to stream the output of the LLM model in realtime:
runs.subscribeToRun method:
runs.subscribeToRun should be used from your backend or another task. To subscribe to a run from
your frontend, you can use our React hooks.useRealtimeRunWithStreams hook to subscribe to a stream:
ai SDKai SDK with the Streams API by using the streamText method:
fullStreamstreamText, you can provide a tools object that allows the LLM to use additional tools. You can then access the tool call and results using the fullStream method:
toolTaskaiStreamingWithTools task. You can also define a Trigger.dev task that can be used as a tool, and will automatically be invoked with triggerAndWait when the tool is called. This is done using the toolTask function: