Skip to main content
Deno 2 is finally here 🎉️
Learn more

openai-chat-stream

Get OpenAI chat response in real-time.

Usage:

import { getCompletionStream } from "https://deno.land/x/openai_chat_stream/mod.ts";

const stream = getCompletionStream({
  apiKey: "YOUR_OPENAI_API_KEY",
  messages: [
    {
      role: "user",
      content: "How is Deno vs Node.js?",
    },
  ],
});

for await (const token of stream) {
  console.info(token);
}