callModel
CallModelInput
*Either
model or models is required.
ProviderPreferences
Configuration for routing and provider selection.RequestOptions
ModelResult
Wrapper providing multiple consumption patterns for a response.Methods
getText()
getResponse()
getTextStream()
getReasoningStream()
getNewMessagesStream()
getFullResponsesStream()
getToolCalls()
getToolCallsStream()
getToolStream()
getContextUpdates()
setContext(). Completes when tool execution finishes.
cancel()
Tool Types
tool()
ToolConfig
* Provide exactly one of
execute or onToolCalled. Omitting both (with execute: false) makes the tool a manual tool.
Tool
Union type of all tool types:ToolWithExecute
Regular tool with execute function:ToolWithGenerator
Generator tool with eventSchema:ManualTool
Tool without execute function:HITLTool
Human-in-the-loop tool withonToolCalled and optional onResponseReceived hooks. outputSchema is required — it validates both the hook’s non-null return value and the caller-supplied response delivered via function_call_output.
null from onToolCalled pauses the loop and sets the conversation status to 'awaiting_hitl'. Throwing from onToolCalled is surfaced as a tool error of the form { error: ... }. Throwing from onResponseReceived is surfaced as an error payload that includes the caller’s original output of the form { error: ..., originalOutput: ... }.
Tool Type Guards
isManualTool— noexecuteand noonToolCalled. Always pauses the loop.isHITLTool— has anonToolCalledfunction.isAutoResolvableTool— either has anexecutefunction (regular/generator) or is a HITL tool. Returnsfalsefor manual and server tools.
Context Types
TurnContext
ToolExecuteContext
Flat context passed to tool execute functions. MergesTurnContext fields with tool-specific context:
ToolContextMap
Context map forcallModel’s context option,
keyed by tool name: