Skip to content

Comment on Consume streaming data from OpenAI with vanilla JavaScript

Comments

umaarOP

Hey HN, have seen a lot of AI demos recently using libraries/frameworks for what is effectively an API call - so thought to showcase how this could be done with vanilla JavaScript. Turns out response.body is an async iterable, so you can do something like:

  for await (const chunk of response.body) { // use chunk }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.