let buffer = ""; for (const chunk of stream.text_stream) { buffer += chunk; process.stdout.write(chunk); } // buffer now contains the full response