openai-sdk
БесплатноБез исполняемых скриптовНе проверенIntegrate OpenAI APIs into applications. Use when a user asks to add GPT or ChatGPT to an app, generate text with OpenAI, build a chatbot, use GPT-6 or…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
OpenAI SDK
Overview
The official openai packages (npm openai, PyPI openai) call the OpenAI API. New code uses the Responses API (client.responses.create); Chat Completions still works but the docs recommend Responses for all new projects, and the GPT-6 Astra and GPT-6.1 Sol models require Responses for tool calling. This skill covers setup, text generation, streaming, function calling, structured outputs, vision, embeddings, moderation, image generation and transcription, and lists what has been shut down so an agent does not reach for it.
Removed or being removed (check https://developers.openai.com/api/docs/deprecations before choosing a model):
- Assistants API: shut down 2026-08-26. Use Responses plus Conversations.
dall-e-2/dall-e-3: shut down 2026-05-12. Use thegpt-image-*models.gpt-3.5-turbo,gpt-4,gpt-4-turbo,o1,o3-mini,o4-mini: shut down 2026-10-23.gpt-5,gpt-5-mini,gpt-5-nano,o3: shut down 2026-12-11.gpt-4o,gpt-4o-mini,gpt-4.1,gpt-4.1-minisnapshots: shut down 2027-01-14.whisper-1,gpt-4o-transcribe*: shut down 2027-02-26.tts-1,gpt-4o-mini-tts: 2027-01-06.
Instructions
Step 1: Install and configure
npm install openai # Node.js 22+ (see engines in package.json)
pip install openai # Python
export OPENAI_API_KEY="sk-proj-..." # the SDKs read this variable themselves
Models in the current docs: gpt-6-astra (most capable), gpt-6.1-sol (balanced), gpt-6-luna (cheapest, high volume). Read the model list at https://developers.openai.com/api/docs/models rather than hard-coding an old name; set the model from an environment variable so a shutdown is a config change.
Step 2: Generate text
import OpenAI from 'openai'
const openai = new OpenAI() // reads OPENAI_API_KEY
const response = await openai.responses.create({
model: 'gpt-6-luna',
instructions: 'You are a helpful coding assistant.', // system-level guidance
input: 'Write a Python function to merge two sorted lists.',
})
console.log(response.output_text)
// Multi-turn: chain on the previous response (stored server-side by default)
const followUp = await openai.responses.create({
model: 'gpt-6-luna',
previous_response_id: response.id,
input: 'Now add type hints and a docstring.',
})
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-6-luna",
instructions="You are a data analysis assistant.",
input="Explain what a p-value is in two sentences.",
)
print(response.output_text)
Reasoning models take reasoning: { effort: 'low' | 'medium' | 'high' } (GPT-6.1 Sol also accepts xhigh and max, and rejects none and minimal).
Step 3: Stream
const stream = await openai.responses.create({
model: 'gpt-6-luna',
input: 'Explain quantum computing in simple terms.',
stream: true,
})
for await (const event of stream) {
if (event.type === 'response.output_text.delta') process.stdout.write(event.delta)
else if (event.type === 'response.completed') console.log('\nDone.')
else if (event.type === 'error') console.error(event.message)
}
For a Next.js route, return a ReadableStream built from these events (or use the Vercel AI SDK's OpenAI provider); the old OpenAIStream / StreamingTextResponse helpers no longer exist in the ai package.
Step 4: Function calling
Responses tools are flat: name, description, parameters sit beside type: 'function'. Keep the model's output items in the input, then append a function_call_output with the same call_id.
import { toResponseInputItems } from 'openai/lib/responses/ResponseInputItems'
const tools = [{
type: 'function' as const,
name: 'get_order_status',
description: 'Look up the status of a customer order',
parameters: {
type: 'object',
properties: { order_id: { type: 'string', description: 'Order number, e.g. ORD-10482' } },
required: ['order_id'],
additionalProperties: false,
},
strict: true,
}]
const input: any[] = [{ role: 'user', content: 'Where is order ORD-10482?' }]
let response = await openai.responses.create({ model: 'gpt-6-luna', tools, input })
input.push(...toResponseInputItems(response.output))
for (const item of response.output) {
if (item.type !== 'function_call') continue
const { order_id } = JSON.parse(item.arguments)
const status = await lookupOrder(order_id) // your code
input.push({ type: 'function_call_output', call_id: item.call_id, output: JSON.stringify(status) })
}
response = await openai.responses.create({ model: 'gpt-6-luna', tools, input })
console.log(response.output_text)
Built-in tools (web_search, file_search, code_interpreter, image_generation, remote MCP) go in the same tools array and run inside one request.
Step 5: Structured outputs
import { zodTextFormat } from 'openai/helpers/zod'
import { z } fr
Установить openai-sdk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл openai-sdk?
Integrate OpenAI APIs into applications. Use when a user asks to add GPT or ChatGPT to an app, generate text with OpenAI, build a chatbot, use GPT-6 or reasoning models, generate embeddings, use function calling, stream responses, get structured JSON, moderate content, generate images, transcribe audio, or migrate from the Assistants API, Chat Completions, DALL-E or Whisper. Covers the Responses API, tools, streaming, vision, embeddings, moderation, image generation and transcription.
Как установить скилл openai-sdk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл openai-sdk запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic