由 fetch 提供支持的简洁且具有主张的 OpenAI 客户端。
A minimal and opinionated OpenAI client powered by fetch.
Unfortunately, the official openai package patches fetch in problematic ways and is quite bloated.
openai-fetch:openai-fetch is ~14kb and openai is ~152kbopenai package if:npm install openai-fetch
This package requires node >= 18 or an environment with fetch support.
This package exports ESM. If your project uses CommonJS, consider switching to ESM or use the dynamic import() function.
import { OpenAIClient } from 'openai-fetch';
const client = new OpenAIClient({ apiKey: '' });
The apiKey is optional and will be read from process.env.OPENAI_API_KEY if present.
The API follows OpenAI very closely, so their reference documentation can generally be used. Everything is strongly typed, so you will know if anything is different as soon as TypeScript parses your code.
…
The type definitions are avaible through TSServer, and can be found here: type definitions.
MIT © Dexa
暂无开放 Issues,或尚未同步最近议题。