# OpenAI — card for AI agents

Official TypeScript SDK for accessing OpenAI APIs including GPT and embeddings.

Category: Model SDKs · npm package `openai` · latest version 7.47.0 (checked 2026-11-01)
Install: `npm install openai`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## OpenAI (openai)
- Use the Responses API (`client.responses.create`) for new code. The README calls Chat Completions the previous standard, which is still supported indefinitely.
- The client reads `OPENAI_API_KEY` by default, so `apiKey` can be omitted. `workloadIdentity` and `apiKey` are mutually exclusive, so pass only one.
- When replaying conversation history by hand, pass the output through `toResponseInputItems()` instead of filtering it to messages. For simple continuation, use `previous_response_id`.
- In webhook handlers, pass the raw request text (not parsed JSON) to `client.webhooks.unwrap()` or `verifySignature()`, and `await` it before trusting the event.
- Catch `OpenAI.APIError` and branch on subclasses such as `RateLimitError`. Log `err.requestID`, or `response._request_id` on successful object responses.
- Retries (2 by default) and the timeout (10 minutes by default) are set with `maxRetries` and `timeout`, on the client or per request.
- Use `toStreamingFile()` instead of `toFile()` when uploading a stream, because `toFile()` buffers stream inputs.

## Agent Skills for it
- Official: openai/skills (43 skills): `npx skills add openai/skills`
- openai-docs from davila7/claude-code-templates: `npx skills add davila7/claude-code-templates --skill openai-docs`
- openai-tts from benchflow-ai/skillsbench: `npx skills add benchflow-ai/skillsbench --skill openai-tts`
- openai from Anil-matcha/awesome-muse-connectors: `npx skills add Anil-matcha/awesome-muse-connectors --skill openai`
- openai-frontend-design from fcakyon/claude-codex-settings: `npx skills add fcakyon/claude-codex-settings --skill openai-frontend-design`

## Docs written for agents
- [llms.txt (index of the docs)](https://platform.openai.com/docs/llms.txt)

## What it is
- The `openai` package is the official JavaScript and TypeScript library for the OpenAI API. The repository was created on 2021-12-14 and is Apache-2.0 licensed. The README says it "provides convenient access to the OpenAI REST API" and is generated from OpenAI's OpenAPI specification. Deno can import it directly as `npm:openai`.
- You create a client, which reads `OPENAI_API_KEY` by default. The README names the Responses API (`client.responses.create`) as the primary way to talk to models. It calls Chat Completions "the previous standard" and says that API is "supported indefinitely". Streaming uses Server-Sent Events, and you consume it with `for await`.
- Most of the README covers the work around a model call: errors, retries, timeouts, cancellation, request IDs, pagination, file uploads and webhook verification. For "secure, automated environments like cloud-managed Kubernetes, Azure, and GCP", it also documents workload identity with short-lived tokens in place of a long-lived API key.

## Caveats
- Hand-built conversation history can break: If you keep only the message items from `response.output`, you can drop reasoning or tool-call items, and the next request may fail. The README points to `toResponseInputItems()`, or to `previous_response_id` for simple continuation.
- 10-minute default timeout, and timeouts retry: By default a request times out after 10 minutes, and you can change this with the `timeout` option. The README notes that timed-out requests are also retried twice by default.
- X.509 auth is Node-only with one endpoint: Certificate-based workload identity needs the optional `undici` peer. It currently supports only the global `https://mtls.api.openai.com/v1` endpoint.
- Cancellation cleanup relies on garbage collection: Keeping a raw response or its body alive can keep its cancellation subscription alive after consumption. On older runtimes without `WeakRef` or `FinalizationRegistry`, the fallback can retain a listener for each successful request until the caller aborts.
- Webhook checks need the raw body: The README says the `body` passed to `unwrap()` or `verifySignature()` must be the raw JSON string sent from the server. Do not parse it first.

## Numbers (AgentGid data)
- Gid Score: 80.8 (#84 of all tools, 4 of 92 in its category)
- Used in 286 public projects set up for AI coding agents (4.6%)
- Downloads last week: 62,533,826 (as of 2026-11-24), +41.0% over 4 weeks
- GitHub stars: 11,276 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
dotenv 58.0%, Zod 60.8%, TypeScript 88.8%, tsx 45.8%, React 65.4%, Express 31.1%

## Checked alternatives (same job)
- Anthropic SDK: https://agentgid.com/tools/anthropic-ai/agent.md
- Google Generative AI: https://agentgid.com/tools/google-genai-npm/agent.md
- Ollama JavaScript Library: https://agentgid.com/tools/ollama-npm/agent.md
- Groq SDK: https://agentgid.com/tools/groq-sdk/agent.md
- Mistral AI: https://agentgid.com/tools/mistralai-mistralai/agent.md
- Replicate: https://agentgid.com/tools/replicate-npm/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/openai-npm/
- Homepage: https://github.com/openai/openai-node#readme
- Repository: https://github.com/openai/openai-node
- Source: https://github.com/openai/openai-node#readme
- Source: https://github.com/openai/openai-node
- Source: https://github.com/openai/openai-node/releases

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
