A minimal and opinionated OpenAI client powered by native fetch (ESM-only, ~14kb). Version 3.4.2 requires Node 18+ or any runtime with built-in fetch. It supports only chat, completions, embeddings, moderations, and TTS endpoints, offering a lean alternative to the official `openai` package (~152kb) that patches fetch. Ships TypeScript types and is actively maintained on GitHub.
npm install openai-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a chat completion using the native fetch client with TypeScript.
Use dynamic import: import('openai-fetch') or switch your project to ESM.Upgrade to Node 18+ or use a fetch polyfill.
Use createCompletion for the singular endpoint.
Always set OPENAI_API_KEY or pass apiKey option explicitly.
import { OpenAIClient } from 'openai-fetch' or use dynamic import.Upgrade to Node >= 18 or use a fetch polyfill like 'node-fetch'.
Set OPENAI_API_KEY or pass apiKey in client constructor.
import type { ChatParams } from 'openai-fetch'No dependency data recorded yet.