openai-node is the official JavaScript and TypeScript library for accessing the OpenAI API.
The library provides a convenient interface to OpenAI's REST API, generated from the official OpenAPI specification. It handles the details of HTTP communication, request formatting, and response parsing, allowing developers to interact with OpenAI models through straightforward method calls. The library supports both the newer Responses API for advanced use cases and the established Chat Completions API, with built-in helpers like toResponseInputItems() to manage multi-turn conversation state correctly by preserving all required output items in order.
Developers building Node.js or browser-based applications that need to call OpenAI models should use this library. It suits projects ranging from simple text generation to complex multi-turn conversations and vision tasks. The library includes workload identity authentication for secure, automated environments, supporting Kubernetes service account tokens, Azure managed identity, GCP compute engine metadata, and X.509 client certificates, making it suitable for cloud-native deployments where API keys are impractical. Deno projects can import the package directly from npm.
The project maintains active development with regular updates to track OpenAI API changes. The codebase shows consistent attention to production concerns, including workload identity support across multiple cloud platforms, careful token refresh management with configurable buffers, and transport-level security features like certificate isolation and retry bounding. The library includes comprehensive examples covering conversation state management, vision capabilities, and authentication patterns across different deployment environments.