Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

openai-api

БесплатноБез исполняемых скриптовНе проверен

OpenAI's traditional stateless APIs: Chat Completions (GPT-5, GPT-5-mini, GPT-5-nano, GPT-4o, GPT-4 Turbo), Embeddings (text-embedding-3-small/large), Images…

jackspaceот jackspace★ 16 звёзд на GitHub12 установок в других каталогах

Об этом скилле

OpenAI API - Complete Guide

Version: Production Ready ✅ Package: [email protected] Last Updated: 2025-10-25


Status

✅ Production Ready:

  • ✅ Chat Completions API (GPT-5, GPT-4o, GPT-4 Turbo)
  • ✅ Embeddings API (text-embedding-3-small, text-embedding-3-large)
  • ✅ Images API (DALL-E 3 generation + GPT-Image-1 editing)
  • ✅ Audio API (Whisper transcription + TTS with 11 voices)
  • ✅ Moderation API (11 safety categories)
  • ✅ Streaming patterns (SSE)
  • ✅ Function calling / Tools
  • ✅ Structured outputs (JSON schemas)
  • ✅ Vision (GPT-4o)
  • ✅ Both Node.js SDK and fetch approaches

Table of Contents

  1. Quick Start
  2. Chat Completions API
  3. GPT-5 Series Models
  4. Streaming Patterns
  5. Function Calling
  6. Structured Outputs
  7. Vision (GPT-4o)
  8. Embeddings API
  9. Images API
  10. Audio API
  11. Moderation API
  12. Error Handling
  13. Rate Limits
  14. Production Best Practices
  15. Relationship to openai-responses

Quick Start

Installation

npm install [email protected]

Environment Setup

export OPENAI_API_KEY="sk-..."

Or create .env file:

OPENAI_API_KEY=sk-...

First Chat Completion (Node.js SDK)

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const completion = await openai.chat.completions.create({
  model: 'gpt-5',
  messages: [
    { role: 'user', content: 'What are the three laws of robotics?' }
  ],
});

console.log(completion.choices[0].message.content);

First Chat Completion (Fetch - Cloudflare Workers)

const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${env.OPENAI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'gpt-5',
    messages: [
      { role: 'user', content: 'What are the three laws of robotics?' }
    ],
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);

Chat Completions API

Endpoint: POST /v1/chat/completions

The Chat Completions API is the core interface for interacting with OpenAI's language models. It supports conversational AI, text generation, function calling, structured outputs, and vision capabilities.

Supported Models

GPT-5 Series (Released August 2025)

  • gpt-5: Full-featured reasoning model with advanced capabilities
  • gpt-5-mini: Cost-effective alternative with good performance
  • gpt-5-nano: Smallest/fastest variant for simple tasks

GPT-4o Series

  • gpt-4o: Multimodal model with vision capabilities
  • gpt-4-turbo: Fast GPT-4 variant

GPT-4 Series

  • gpt-4: Original GPT-4 model

Basic Request Structure

{
  model: string,              // Model to use (e.g., "gpt-5")
  messages: Message[],        // Conversation history
  reasoning_effort?: string,  // GPT-5 only: "minimal" | "low" | "medium" | "high"
  verbosity?: string,         // GPT-5 only: "low" | "medium" | "high"
  temperature?: number,       // NOT supported by GPT-5
  max_tokens?: number,        // Max tokens to generate
  stream?: boolean,           // Enable streaming
  tools?: Tool[],             // Function calling tools
}

Response Structure

{
  id: string,                 // Unique completion ID
  object: "chat.completion",
  created: number,            // Unix timestamp
  model: string,              // Model used
  choices: [{
    index: number,
    message: {
      role: "assistant",
      content: string,        // Generated text
      tool_calls?: ToolCall[] // If function calling
    },
    finish_reason: string     // "stop" | "length" | "tool_calls"
  }],
  usage: {
    prompt_tokens: number,
    completion_tokens: number,
    total_tokens: number
  }
}

Message Roles

OpenAI supports three message roles:

  1. system (formerly "developer"): Set behavior and context
  2. user: User input
  3. assistant: Model responses
const messages = [
  {
    role: 'system',
    content: 'You are a helpful assistant that explains complex topics simply.'
  },
  {
    role: 'user',
    content: 'Explain quantum computing to a 10-year-old.'
  }
];

Multi-turn Conversations

Build conversation history by appending messages:

const messages = [
  { role: 'system', content: 'You are a helpful assistant.' },
  { role: 'user', content: 'What is TypeScript?' },
  { role: 'assistant', content: 'TypeScript is a superset of JavaScript...' },
  { role: 'user', content: 'How do I install it?' }
];

const completion = await openai.chat.completions
Полный SKILL.md на GitHub

Установить openai-api в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

NEXT-SESSION.mdREADME.mdSKILL.json

FAQ

Что делает скилл openai-api?

OpenAI's traditional stateless APIs: Chat Completions (GPT-5, GPT-5-mini, GPT-5-nano, GPT-4o, GPT-4 Turbo), Embeddings (text-embedding-3-small/large), Images (DALL-E 3 generation, GPT- Image-1 editing), Audio (Whisper transcription and TTS), and Moderation. Covers the openai Node.js SDK and plain fetch for edge runtimes, SSE streaming, function calling and tools, structured outputs with JSON schemas, vision, GPT-5 reasoning_effort and verbosity, error handling, and rate limits. Use when integrating OpenAI into an application, streaming chat completions, generating embeddings for RAG, creating images, transcribing or synthesizing speech, moderating content, deploying OpenAI calls on Cloudflare Workers, or debugging 429 rate limits, 401 invalid API keys, function calling failures, streaming parse errors, embedding dimension mismatches, or token limit exceeded.

Как установить скилл openai-api?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл openai-api запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить openai-api с