Complete guide for OpenAI APIs: Chat Completions (GPT-5.2, GPT-4o), Embeddings, Images (GPT-Image-1.5), Audio (Whisper + TTS + Transcribe), Moderation. Includes Node.js SDK and fetch approaches.
Integrates OpenAI APIs for chat, embeddings, images, audio, and moderation with Node.js SDK.
npx claudepluginhub secondsky/claude-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/audio-guide.mdreferences/cost-optimization.mdreferences/embeddings-guide.mdreferences/error-catalog.mdreferences/function-calling-patterns.mdreferences/images-guide.mdreferences/models-guide.mdreferences/structured-output-guide.mdreferences/top-errors.mdscripts/check-versions.shtemplates/audio-transcription.tstemplates/basic-usage.tstemplates/chat-completion-basic.tstemplates/chat-completion-nodejs.tstemplates/cloudflare-worker.tstemplates/embeddings.tstemplates/function-calling.tstemplates/image-editing.tstemplates/image-generation.tstemplates/moderation.tsPackage: openai@6.9.1 | Last Updated: 2025-11-21
bun add openai
export OPENAI_API_KEY="sk-..."
import OpenAI from 'openai';
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }]
});
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant' },
{ role: 'user', content: 'Explain AI' }
],
temperature: 0.7,
max_tokens: 1000
});
const stream = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Tell a story' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What is the weather?' }],
tools: [{
type: 'function',
function: {
name: 'getWeather',
parameters: {
type: 'object',
properties: { location: { type: 'string' } },
required: ['location']
}
}
}]
});
const response = await client.embeddings.create({
model: 'text-embedding-3-small',
input: 'Your text here'
});
const embedding = response.data[0].embedding; // 1536 dimensions
const image = await client.images.generate({
model: 'gpt-image-1.5',
prompt: 'A serene landscape',
size: '1024x1024',
quality: 'standard' // or 'hd'
});
Transcription (Whisper):
const transcription = await client.audio.transcriptions.create({
file: fs.createReadStream('audio.mp3'),
model: 'whisper-1'
});
Text-to-Speech:
const speech = await client.audio.speech.create({
model: 'tts-1',
voice: 'alloy',
input: 'Hello world'
});
See: references/error-catalog.md
references/models-guide.md - Complete model comparison and selectionreferences/function-calling-patterns.md - Function calling best practicesreferences/structured-output-guide.md - Structured outputs with JSON Schemareferences/embeddings-guide.md - Text embeddings and vector searchreferences/images-guide.md - GPT-Image-1.5 image generationreferences/audio-guide.md - Whisper transcription + TTSreferences/cost-optimization.md - Token optimization and pricingreferences/top-errors.md - Top 20 errors with solutionsreferences/error-catalog.md - Complete error referencetemplates/basic-usage.ts - Quick start exampletemplates/chat-completion-basic.ts - Basic chat completiontemplates/chat-completion-nodejs.ts - Node.js implementationtemplates/streaming-chat.ts - Streaming responsestemplates/streaming-fetch.ts - Streaming with fetch APItemplates/function-calling.ts - Tools and function callingtemplates/structured-output.ts - JSON Schema outputstemplates/vision-gpt4o.ts - Vision with GPT-4otemplates/embeddings.ts - Text embeddingstemplates/image-generation.ts - GPT-Image-1.5 generationtemplates/image-editing.ts - Image editingtemplates/audio-transcription.ts - Whisper transcriptiontemplates/text-to-speech.ts - TTS with voicestemplates/moderation.ts - Content moderationtemplates/rate-limit-handling.ts - Exponential backofftemplates/cloudflare-worker.ts - Cloudflare Workers integrationThis skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.