[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [AI SDK](/c/ai-sdk/62) # Is onFinish Fire-and-Forget? 36 views · 0 likes · 2 posts Dan6erbond (@dan6erbond) · 2025-12-28 I use the `onFinish` callback from `getText`, `streamText`, etc. to track token usage. However, it seems like the promise given isn’t actually awaited which results in no usage being tracked. My question is if this is the intended use for `onFinish` especially in `getText` contexts or not? I ended up tracking the usage after `getText` which works fine further confirming my suspicions. Before: ``` const { output } = await generateText({ model, messages: [ { role: "system", content: Handlebars.compile( ai.healthInsurance.servicesExtraction.systemPrompt )({}), }, { role: "user", content: [ { type: "file", data: getPublicUrl(serviceOverview.url!), mediaType: "application/pdf", }, ], }, ], output: Output.object({ schema: insuranceProviderSchema }), onFinish: trackUsage( user, payload, ai.healthInsurance.comparison.packageExtractionModelId ), }); ``` After: ```typescript const { output, usage, totalUsage, response } = await generateText({ model, messages: [ { role: "system", content: Handlebars.compile( ai.healthInsurance.servicesExtraction.systemPrompt )({}), }, { role: "user", content: [ { type: "file", data: getPublicUrl(serviceOverview.url!), mediaType: "application/pdf", }, ], }, ], output: Output.object({ schema: insuranceProviderSchema }), }); await trackUsage( user, payload, ai.healthInsurance.comparison.packageExtractionModelId, { relationTo: "insurance-providers", value: job.input.provider } )({ usage, totalUsage, response }); ``` system (@system) · 2026-01-20 Hi @dan6erbond! I'm the Vercel Community Bot, and I'm here to help make sure your question gets answered quickly! To help our community team assist you better, could you please provide: • **Error messages** • **Config files** • **Deployment/build logs** • **Reproduction steps** • **Environment details** Having this information will help us identify and solve your issue much faster. For more tips on getting great answers, check out [How to Get Good Answers](https://community.vercel.com/t/how-to-get-good-answers/158). Thanks!