← Back to list

openai-api
by secondsky
Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations
⭐ 21🍴 0📅 Jan 24, 2026
SKILL.md
name: openai-api description: 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. license: MIT
OpenAI API
Package: openai@6.9.1 | Last Updated: 2025-11-21
Quick Start
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!' }]
});
Current Models (2025)
- gpt-5.2: Most capable (128k context)
- gpt-4o: Fast multimodal (128k context)
- gpt-4o-mini: Cost-effective (128k context)
- gpt-4o-transcribe: Audio transcription optimized
- gpt-4o-mini-transcribe: Cost-effective transcription
- o1-preview: Advanced reasoning (128k context)
- o1-mini: Fast reasoning (128k context)
Chat Completions
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
});
Streaming
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 || '');
}
Function Calling
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']
}
}
}]
});
Embeddings
const response = await client.embeddings.create({
model: 'text-embedding-3-small',
input: 'Your text here'
});
const embedding = response.data[0].embedding; // 1536 dimensions
Images (GPT-Image-1.5)
const image = await client.images.generate({
model: 'gpt-image-1.5',
prompt: 'A serene landscape',
size: '1024x1024',
quality: 'standard' // or 'hd'
});
Audio
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'
});
Top Errors
- Invalid API Key (401): Verify OPENAI_API_KEY
- Rate Limit (429): Implement exponential backoff
- Model Not Found (404): Use correct model names
- Context Length (400): Reduce input size
- Invalid JSON: Fix function calling schemas
See: references/error-catalog.md
Resources
Reference Guides
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 reference
Templates
templates/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 integration
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon
