Define a chat task
Use
chat.task from @trigger.dev/sdk/ai to define a task that handles chat messages. The run function receives ModelMessage[] (already converted from the frontend’s UIMessage[]) — pass them directly to streamText.If you return a StreamTextResult, it’s automatically piped to the frontend.trigger/chat.ts
Generate an access token
On your server (e.g. a Next.js server action), create a trigger public token scoped to your chat task:
app/actions.ts

