[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [AI SDK](/c/ai-sdk/62) # OnFinishResult Type 313 views · 5 likes · 4 posts Ben (@frescoanalytics) · 2025-06-14 · ♥ 1 <!-- Questions that get answered the fastest are the ones with relevant info included in the original post. Be sure to include all detail needed to let others see and understand the problem! --> I was looking at this part of the document on using onFinish callback. https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-text#on-finish 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. <!-- Current versus Expected behavior --> Currently my IDE is suggesting type "any". <!-- Code, configuration, and steps that reproduce this issue --> ``` 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, }); ``` <!-- Project information (URL, framework, environment, project settings) --> Ben (@frescoanalytics) · 2025-06-14 · ♥ 1 I found this line can be useful to define the type. ``` let onFinishResult: Parameters< Required<Parameters<typeof streamText>[0]>['onFinish'] >[0]; ``` https://github.com/vercel/ai/blame/26e70676e17e84a3e6d3054722365325a14cdc00/packages/ai/core/generate-text/stream-text.test.ts#L2315 BestCodes (@bestcodes) · 2025-06-14 · ♥ 1 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 :smiley: BestCodes (@bestcodes) · 2025-06-14 · ♥ 2 I did create a PR, but it's very small and maybe not necessary with the workarounds discussed here :smiling_face_with_tear: https://github.com/vercel/ai/pull/6749