Hi @alex.w, welcome to the community!
I understand you’re using the algolia-sitemap package. As it’s currently written, it will output to a single file without options to stream.
However, you could use the code found here as a base and the modify it to write in a stream rather than aggregate all hits and then write to a file.
The generator is making use of the browse function to read all of the records in an index, transform them into a entires in a sitemap, aggregate them and then write the aggregated data. Instead, you could be writing/sending these entries each time a batch of record is found from the browse function.
I know this is very high level, but I hope it helps. Please feel free to ask further questions!