Optional
options: { parser?: MessageParser<O>; request?: GenerateRequest<ZodTypeAny> }Provider-specific response data.
Optional
finishAdditional information about why the model stopped generating, if any.
The reason generation stopped for this request.
Optional
messageThe generated message.
Optional
parserThe parser for output parsing of this response.
Optional
requestThe request that generated this response.
Usage information.
Returns all tool requests annotated as interrupts found in the generated message.
A list of ToolRequestParts.
Returns the first detected media part in the generated message. Useful for extracting (for example) an image from a generation expected to create one.
The first detected media
part in the candidate.
Appends the message generated by the selected candidate to the messages already present in the generation request. The result of this method can be safely serialized to JSON for persistence in a database.
A serializable list of messages compatible with generate({history})
.
If the generated message contains a data
part, it is returned. Otherwise,
the output()
method extracts the first valid JSON object or array from the text
contained in the selected candidate's message and returns it.
The structured output contained in the selected candidate.
Concatenates all text
parts present in the generated message with no delimiter.
A string of all concatenated text parts.
Returns all tool request found in the generated message.
Array of all tool request found in the candidate.
Throws an error if the response does not conform to expected schema.
Optional
request: GenerateRequest<ZodTypeAny>Optional
request: GenerateRequest<ZodTypeAny>
GenerateResponse is the result from a
generate()
call and contains one or more generated candidate messages.