TypeScript/JavaScript SDK for the OpenAI API
Top 5.3% on sourcepulse
This library provides a robust and officially supported JavaScript/TypeScript interface for interacting with the OpenAI API. It's designed for developers building applications that leverage OpenAI's language models, offering convenient access to features like text generation, streaming responses, file uploads, and error handling.
How It Works
The library is generated directly from OpenAI's OpenAPI specification using Stainless, ensuring fidelity to the API's structure. It supports both the newer "Responses" API for text generation and the established "Chat Completions" API. Key features include automatic retries for transient errors, configurable timeouts, and support for Server-Sent Events (SSE) for streaming responses.
Quick Start & Requirements
npm install openai
deno add jsr:@openai/openai
or npx jsr add @openai/openai
dangerouslyAllowBrowser: true
.Highlighted Details
Responses
and Chat Completions
APIs.fs.ReadStream
, File
objects, fetch
Responses, or a toFile
helper.APIError
subclasses.AzureOpenAI
class for Azure OpenAI service integration.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
dangerouslyAllowBrowser: true
) and carries security risks if API keys are exposed client-side.3 days ago
1 day