Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai node Package Manifest

From Leeroopedia
Revision as of 13:36, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_node_Package_Manifest.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains SDK, Package Configuration
Last Updated 2026-02-15 12:00 GMT

Overview

The package.json manifest defines the openai NPM package metadata, entry points, exports map, peer dependencies, and build/test scripts for the OpenAI Node.js SDK.

Description

The package manifest declares the openai package at version 6.22.0, described as "The official TypeScript library for the OpenAI API" and authored by OpenAI. It is published under the Apache-2.0 license as a CommonJS module ("type": "commonjs") with TypeScript type definitions at dist/index.d.ts and the main entry point at dist/index.js.

The exports map provides dual CJS/ESM support via conditional exports: the root "." export maps import to ./dist/index.mjs and require to ./dist/index.js, with wildcard patterns supporting deep imports of individual modules in both formats. The package exposes an openai CLI binary at bin/cli.

The package has zero runtime dependencies -- its dependencies field is empty. It declares two optional peer dependencies: ws (version ^8.18.0) for Node.js WebSocket support in the realtime client, and zod (version ^3.25 or ^4.0) for structured output parsing with Zod schemas. Both are marked as optional in peerDependenciesMeta. The devDependencies include TypeScript 5.8.3, Jest for testing, ESLint with Prettier for linting, and various build tools including a custom tsc-multi package for multi-target compilation.

Usage

This manifest is the foundation for installing and consuming the SDK. Developers install it via npm install openai or yarn add openai and can optionally install ws for Node.js realtime support or zod for structured output features.

Code Reference

Source Location

Signature

// Key fields from package.json
{
  "name": "openai",
  "version": "6.22.0",
  "types": "dist/index.d.ts",
  "main": "dist/index.js",
  "type": "commonjs",
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.js"
    },
    "./*": {
      "import": "./dist/*.mjs",
      "require": "./dist/*.js"
    }
  },
  "bin": { "openai": "bin/cli" }
}

Import

import OpenAI from 'openai';
// or
const OpenAI = require('openai');

I/O Contract

Inputs

Name Type Required Description
(install) npm install openai Yes Installs the package and its zero runtime dependencies.
ws npm install ws No (optional peer) Required for Node.js WebSocket-based realtime API support.
zod npm install zod No (optional peer) Required for Zod-based structured output parsing helpers.

Outputs

Name Type Description
dist/index.js CommonJS module Main CJS entry point for require('openai').
dist/index.mjs ES module ESM entry point for import OpenAI from 'openai'.
dist/index.d.ts TypeScript declarations Full TypeScript type definitions for the SDK.
bin/cli executable The openai CLI tool binary.

Usage Examples

// Install the package
// npm install openai

// Optional peer dependencies
// npm install ws    # For Node.js realtime WebSocket support
// npm install zod   # For structured output Zod helpers

// ESM import
import OpenAI from 'openai';

// CJS require
const OpenAI = require('openai');

// Deep import of a specific sub-module
import { zodResponseFormat } from 'openai/helpers/zod';

// Using the CLI
// npx openai --help

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment