I was looking at this part of the document on using onFinish callback.
The document provides that the callback function take a parameter of OnFinishResult type. Can anyone please help me understand how to import this type? I’d be useful if I write the callback in other places than the inline function.
Currently my IDE is suggesting type “any”.
async function onFinishCallback(result: any): Promise<void> {
// This function is called when the AI has finished generating a response.
console.log('\nAI response finished:', result);
}
const result = streamText({
model: google('gemini-2.5-flash-preview-05-20'),
system: 'you are an assistant.',
messages,
providerOptions: /*something*/,
onFinish: onFinishCallback,
});
Looks like you are right. I looked around in the codebase and didn’t see any official OnFinishResult type (besides the type you mentioned used in testing). I might make a PR for this