.agents/skills/xsai/references/text-stream-tools.md
Use this reference for generateText, streamText, chat options, and tool loops.
Most text APIs in xsAI use:
apiKeybaseURLmodelmessagesfetch, headers, abortSignalFor chat-style APIs, expect common options such as:
temperaturetopPstopseedtoolChoicetoolsmaxStepsgenerateTextUse generateText when the user wants one final result.
Returns a result shaped like:
textfinishReasonusagemessagesstepstoolCallstoolResultsreasoningTextstreamTextUse streamText when the user wants incremental output or tool events.
It returns immediately and exposes:
textStreamfullStreamreasoningTextStreammessages as a promisesteps as a promiseusage as a promisetotalUsage as a promisefullStream may contain events such as:
text-deltareasoning-deltatool-call-streaming-starttool-call-deltatool-calltool-resultfinisherrormaxSteps enables repeated tool-use loops.toolChoice: 'required' when the model must call a tool.generateText for simple examples, scripts, and tests.streamText for UIs, live output, agent-like flows, and event-driven integrations.streamText plus tools is a good fit.