Agent skill · Backend & API

api-ai-openai-sdk

Official OpenAI SDK patterns for TypeScript/Node.js — client setup, Chat Completions, Responses API, streaming, structured outputs, function calling, embeddings, vision, audio, and production best practices

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-ai-openai-sdk --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 21 KB
Bundled scripts: none
Path: skills/ai-llm/api-ai-openai-sdk/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Provides patterns to use the official OpenAI SDK (TypeScript/Node.js) for client setup, Chat Completions, the Responses API, streaming, structured outputs, function calling, embeddings, vision, audio, and batch processing.

How it works

  • Recommends using the official npm package openai (v6+) and choosing between client.responses.create() (Responses API) and client.chat.completions.create() (Chat Completions) depending on the project.
  • Enforces use of zodResponseFormat() for structured outputs and client.chat.completions.parse() to parse responses.
  • Uses .stream() or stream: true for streaming, and supports event-based or iterable consumption (for await...of).
  • Includes patterns for embedding, vision, audio, and batch processing via respective APIs.
  • Emphasizes error handling with OpenAI.APIError and configured retries/timeouts (default retries on 429/5xx).
  • Requires environment variable OPENAI_API_KEY for API keys.
  • Provides examples around client setup, chat completions, streaming, tool calling with zodFunction, and structured outputs.

When to use it

  • Building applications that call OpenAI models directly (GPT-5.x, GPT-4o, o4-mini, etc.).
  • Implementing chat completions with streaming responses.
  • Using the Responses API for agentic workflows with built-in tools (web/file search, code interpreter).
  • Extracting structured data from LLM responses with Zod schema validation.
  • Implementing function calling / tool use with Chat Completions or Responses API.
  • Creating embeddings for RAG or semantic search.
  • Processing images with vision models or audio with Whisper/TTS.
  • Running batch jobs for high-volume, cost-efficient processing.

What it can touch

  • Client: client.responses.create() and client.chat.completions.create() for main interactions.
  • Structured outputs via zodResponseFormat() and client.chat.completions.parse().
  • Tools integration via zodFunction() and optional runTools() for automated tool loops.
  • Embeddings: client.embeddings.create().
  • Vision/Audio: client.audio.transcriptions.create() and client.audio.speech.create(), plus image handling with image_url/base64.
  • Batch API via client.batches.create().
  • Error handling with OpenAI.APIError and subclasses; environment-based configuration for retries/timeouts.

Caveats

  • LICENSE: MIT. (Not a detail about usage but present in the skill metadata.)
  • Requires adherence to project conventions (kebab-case, named exports, import ordering, import type, named constants).
  • Not to be used for multi-provider switching; openAI-specific patterns only.
  • Avoids hardcoding API keys; uses process.env.OPENAI_API_KEY.
From the SKILL.md

# OpenAI SDK Patterns > **Quick Guide:** Use the official `openai` npm package (v6+) to interact with OpenAI's API directly. Use `client.responses.create()` (Responses API) for new projects with built-in tools and server-side state, or `client.chat.completions.create()` (Chat Completions) for stateless chat flows. Use `zodResponseFormat` and `client.chat.completions.parse()` for structured outputs. Use `.stream()` or `stream: true` for streaming. Supports GPT-5.x family, GPT-4o, o4-mini, embeddings, vision, audio, and batch processing. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST use the Responses API (`client.responses.create()`) for new projects -- it provides better performance, built-in tools, and server-side conversation state)** **(You MUST use `zodResponseFormat()` from `openai/helpers/zod` for structured outputs -- do NOT manually construct JSON schemas)** **(You MUST handle errors using `OpenAI.APIError` and its subclasses -- never use bare catch blocks without error type checking)** **(You MUST configure a

What's inside
Steps it walks through
  1. CRITICAL: Before Using This Skill
  2. Examples Index
  3. Philosophy
  4. Core Patterns
  5. Pattern 1: Client Setup
  6. Pattern 2: Chat Completions API
  7. Pattern 3: Responses API (Recommended for New Projects)
  8. Pattern 4: Streaming
  9. Pattern 5: Structured Outputs with Zod
  10. Pattern 6: Function Calling / Tool Use
  11. Pattern 7: Embeddings, Vision & Audio
  12. Pattern 8: Error Handling
  13. Performance Optimization
  14. Model Selection for Cost/Speed
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-ai-openai-sdk skill do?

Official OpenAI SDK patterns for TypeScript/Node.js — client setup, Chat Completions, Responses API, streaming, structured outputs, function calling, embeddings, vision, audio, and production best practices

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-openai-sdk --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going