openai-stream-mini
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

openai-stream-mini

OpenAI client with no dependencies (except Node 18 or browser) that supports streaming completion text.

Usage

import { OnTextCallback, streamCompletion } from "openai-stream-mini";
import type { CreateCompletionRequest } from "openai";

const apiKey = process.env.OPENAI_API_KEY;
const args: CreateCompletionRequest = {
  prompt: "What is the greatest toilet in the world?",
  model: "text-davinci-003",
  max_tokens: 2500,
  temperature: 0.9,
};
const handleText: OnTextCallback = async (text) => {
  if (!text) return;
  console.log(text);
};

const text = await streamCompletion({ args, apiKey, onText: handleText });

/openai-stream-mini/

    Package Sidebar

    Install

    npm i openai-stream-mini

    Weekly Downloads

    1

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    18 kB

    Total Files

    9

    Last publish

    Collaborators

    • cybermischa