# openai-stream-mini

> Lightweight OpenAI completion streaming client for Node.js and the browser

Latest version **1.0.12** (published 2023-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install openai-stream-mini
pnpm add openai-stream-mini
yarn add openai-stream-mini
bun add openai-stream-mini
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2023-05-31 |
| First published | 2023-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.18 |
| Dependencies | 0 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Mischa Spiegelmock |
| Maintainers | cybermischa |
| Keywords | openai, stream, node, browser |

## Links

- npm: https://www.npmjs.com/package/openai-stream-mini
- Repository: https://github.com/revmischa/openai-stream-mini
- Homepage: https://github.com/revmischa/openai-stream-mini#readme
- Issues: https://github.com/revmischa/openai-stream-mini/issues
- npm.io page: https://npm.io/package/openai-stream-mini

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2023-05-31
- 1.0.10 — 2023-03-10
- 1.0.9 — 2023-03-10
- 1.0.8 — 2023-03-10
- 1.0.7 — 2023-03-10
- 1.0.6 — 2023-03-09
- 1.0.5 — 2023-03-09
- 1.0.3 — 2023-03-09
- 1.0.2 — 2023-03-09
- 1.0.1 — 2023-03-09
- 1.0.0 — 2023-03-09

## README

# openai-stream-mini

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

## Usage

```ts
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 });
```

---
_Source: https://npm.io/package/openai-stream-mini · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
