new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

AI SDK · Core · all subjects

generatetext options

17 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

generateText toolChoice parameter

The 'toolChoice' parameter is optional with type '"auto" | "none" | "required" | { "type": "tool", "toolName": string }'. It specifies how tools are selected for execution. The default is "auto". "none" disables tool execution. "required" requires tools to be executed. { "type": "tool", "toolName": string } specifies a specific tool to execute.

generateText activeTools parameter

The 'activeTools' parameter is optional (type 'ActiveTools<TOOLS>'). It limits the tools that are available for the model to call without changing the tool call and result types in the result. All tools are active by default. Tool names are restricted to the string keys of the tool set.

generateText toolOrder parameter

The 'toolOrder' parameter is optional (type 'ToolOrder<TOOLS>'). It controls the order in which tools are sent to the provider. The list can be partial. Tools not listed in toolOrder are sent after the listed tools, sorted alphabetically. Tool names are restricted to the string keys of the tool set.

generateText toolApproval parameter

The 'toolApproval' parameter is optional (type 'ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT>'). It specifies approval configuration for this call. Pass a GenericToolApprovalFunction to handle all tool calls in one callback with toolCall, tools, toolsContext, messages, and runtimeContext, or pass a per-tool object where each key can be a status ('not-applicable', 'approved', 'denied', or 'user-approval'), an object form such as { type: 'denied', reason: 'blocked by policy' }, or a SingleToolApprovalFunction. The RUNTIME_CONTEXT type parameter matches the call's runtimeContext. A GenericToolApprovalFunction or SingleToolApprovalFunction may return undefined for the same effect as 'not-applicable'. 'not-applicable' is the default execution path and runs the tool without approval metadata. This setting takes precedence over a tool's needsApproval default.

generateText experimental_toolCallers parameter

The 'experimental_toolCallers' parameter is optional (type 'Experimental_ToolCallers<TOOLS>'). It configures which caller tools may invoke each tool. The callback receives typed references for caller-capable tools in the tools set and returns an object keyed by callee tool name. Include 'direct' to keep a configured tool directly callable by the model. Local-only callees are hidden from direct model calls and bound to their local caller for each generation step. Provider caller references are translated to provider-native allowed-caller options. Tools without an entry keep their existing direct tool-calling behavior.

generateText stopWhen parameter

The 'stopWhen' parameter is optional (type 'StopCondition<TOOLS> | Array<StopCondition<TOOLS>>'). It specifies a condition for stopping the generation when there are tool results in the last step. When the condition is an array, any of the conditions can be met to stop the generation. Default is isStepCount(1).

generateText prepareStep parameter

The 'prepareStep' parameter is optional (type '(options: PrepareStepOptions) => PrepareStepResult<TOOLS> | Promise<PrepareStepResult<TOOLS>>'). It is an optional function that you can use to provide different settings for a step. You can modify the model, model call settings, tool choices, active tools, instructions, input messages, and experimental sandbox for each step.

PrepareStepOptions type definition

PrepareStepOptions has nine properties: steps (type 'Array<StepResult<TOOLS>>', required, the steps that have been executed so far), stepNumber (type 'number', required, the number of the step being executed), model (type 'LanguageModel', required), instructions (type 'Instructions | undefined', required, the instructions that will be sent to the model for the current step), initialInstructions (type 'Instructions | undefined', required, the initial instructions passed into generateText or streamText), messages (type 'Array<ModelMessage>', required, the messages that will be sent to the model for the current step), runtimeContext (type 'CONTEXT', optional), toolsContext (type 'InferToolSetContext<TOOLS>', required, the per-tool context map), and experimental_sandbox (type 'Experimental_SandboxSession | undefined', optional).

PrepareStepResult return value fields

PrepareStepResult can return optional overrides for: model (LanguageModel), maxOutputTokens (number), temperature (number), topP (number), topK (number), presencePenalty (number), frequencyPenalty (number), stopSequences (string[]), seed (number), reasoning (LanguageModelV4CallOptions['reasoning']), toolChoice (ToolChoice<TOOLS>), activeTools (ActiveTools<TOOLS>), toolOrder (ToolOrder<TOOLS>), instructions (Instructions), messages (Array<ModelMessage>), runtimeContext (CONTEXT), toolsContext (InferToolSetContext<TOOLS>), experimental_sandbox (Experimental_SandboxSession), and providerOptions (ProviderOptions). All are optional.

generateText toolsContext parameter

The 'toolsContext' parameter is optional (type 'InferToolSetContext<TOOLS>'). It is a per-tool context map keyed by tool name. It is required when at least one tool defines contextSchema; not accepted when no tools need context.

generateText include parameter

The 'include' parameter is optional (type '{ requestBody?: boolean; requestMessages?: boolean; responseBody?: boolean }'). It controls inclusion of request bodies, request messages, and response bodies in step results. By default, request bodies, request messages, and response bodies are excluded to reduce memory usage. Set requestBody, requestMessages, and/or responseBody to true when you need access to the data.

generateText repairToolCall parameter

The 'repairToolCall' parameter is optional (type '(options: ToolCallRepairOptions) => Promise<LanguageModelV4ToolCall | null>'). It is a function that attempts to repair a tool call that failed to parse. Return either a repaired tool call or null if the tool call cannot be repaired.

ToolCallRepairOptions type definition

ToolCallRepairOptions has seven properties: instructions (type 'Instructions | undefined', required), system (type 'Instructions | undefined', optional, deprecated in favor of instructions), messages (type 'ModelMessage[]', required, the messages in the current generation step), toolCall (type 'LanguageModelV4ToolCall', required, the tool call that failed to parse), tools (type 'TOOLS', required, the available tools), inputSchema (type '(options: { toolName: string }) => JSONSchema7', required, a function that returns the JSON Schema for a tool), and error (type 'NoSuchToolError | InvalidToolInputError', required, the error that occurred while parsing the tool call).

generateText output parameter

The 'output' parameter is optional (type 'Output'). It specifies parsing of structured outputs from the LLM response. Available output specifications include: Output.text() for text generation (default), Output.object() for typed object generation using schemas, Output.array() for array generation, Output.choice() for choice generation, and Output.json() for unstructured JSON generation.

Output.array specification

Output.array() accepts options with element (type 'Schema<ELEMENT>', required), minItems (type 'number', optional, non-negative integer), maxItems (type 'number', optional, non-negative integer, must be >= minItems), name (type 'string', optional), and description (type 'string', optional). When the model generates a text response, it will return an array of elements.

Output.choice specification

Output.choice() accepts options with options (type 'Array<string>', required), name (type 'string', optional), and description (type 'string', optional). When the model generates a text response, it will return one of the choice options.

Output.json specification

Output.json() accepts options with name (type 'string', optional) and description (type 'string', optional). When the model generates a text response, it will return a JSON object.

Give your agent this brain