openai-api

OpenAI API integration for building AI-powered applications. Use when working with OpenAI's Chat Completions API, Python SDK (openai), TypeScript SDK (openai), tool use/function calling, vision/image inputs, streaming responses, DALL-E image generation, Whisper audio transcription, text-to-speech, embeddings, Assistants API, fine-tuning, or any OpenAI API integration task. Triggers on mentions of OpenAI, GPT-4, GPT-4o, GPT-5, o1, o3, o4, DALL-E, Whisper, Sora, or OpenAI SDK usage.

16 stars

Best use case

openai-api is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

OpenAI API integration for building AI-powered applications. Use when working with OpenAI's Chat Completions API, Python SDK (openai), TypeScript SDK (openai), tool use/function calling, vision/image inputs, streaming responses, DALL-E image generation, Whisper audio transcription, text-to-speech, embeddings, Assistants API, fine-tuning, or any OpenAI API integration task. Triggers on mentions of OpenAI, GPT-4, GPT-4o, GPT-5, o1, o3, o4, DALL-E, Whisper, Sora, or OpenAI SDK usage.

Teams using openai-api should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/openai-api/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/ai-agents/openai-api/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/openai-api/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How openai-api Compares

Feature / Agentopenai-apiStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

OpenAI API integration for building AI-powered applications. Use when working with OpenAI's Chat Completions API, Python SDK (openai), TypeScript SDK (openai), tool use/function calling, vision/image inputs, streaming responses, DALL-E image generation, Whisper audio transcription, text-to-speech, embeddings, Assistants API, fine-tuning, or any OpenAI API integration task. Triggers on mentions of OpenAI, GPT-4, GPT-4o, GPT-5, o1, o3, o4, DALL-E, Whisper, Sora, or OpenAI SDK usage.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# OpenAI API

Build AI applications using OpenAI's APIs with Python or TypeScript SDKs.

## Quick Start

### Installation

```bash
# Python
pip install openai

# TypeScript/Node.js
npm install openai
```

### Client Setup

**Python:**
```python
from openai import OpenAI

client = OpenAI()  # Uses OPENAI_API_KEY env var
# Or: client = OpenAI(api_key="sk-...")
```

**TypeScript:**
```typescript
import OpenAI from 'openai';

const client = new OpenAI();  // Uses OPENAI_API_KEY env var
// Or: new OpenAI({ apiKey: 'sk-...' })
```

## Chat Completions

Basic chat completion:

**Python:**
```python
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)
print(response.choices[0].message.content)
```

**TypeScript:**
```typescript
const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
        { role: 'system', content: 'You are a helpful assistant.' },
        { role: 'user', content: 'Hello!' }
    ]
});
console.log(response.choices[0].message.content);
```

### Streaming

**Python:**
```python
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

**TypeScript:**
```typescript
const stream = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Tell me a story' }],
    stream: true
});
for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
```

### Tool Use / Function Calling

**Python:**
```python
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current weather for a location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "City name"}
            },
            "required": ["location"]
        }
    }
}]

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools
)

# Check if tool call requested
if response.choices[0].message.tool_calls:
    tool_call = response.choices[0].message.tool_calls[0]
    # Execute function, then send result back
    messages.append(response.choices[0].message)
    messages.append({
        "role": "tool",
        "tool_call_id": tool_call.id,
        "content": '{"temp": 22, "condition": "sunny"}'
    })
```

**TypeScript:**
```typescript
const tools: OpenAI.ChatCompletionTool[] = [{
    type: 'function',
    function: {
        name: 'get_weather',
        description: 'Get current weather for a location',
        parameters: {
            type: 'object',
            properties: {
                location: { type: 'string', description: 'City name' }
            },
            required: ['location']
        }
    }
}];

const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: "What's the weather in Paris?" }],
    tools
});

if (response.choices[0].message.tool_calls) {
    const toolCall = response.choices[0].message.tool_calls[0];
    // Execute function, then continue conversation
}
```

### Vision (Image Input)

**Python:**
```python
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]
    }]
)
```

For base64 images: `"url": "data:image/jpeg;base64,{base64_string}"`

### Structured Outputs (JSON Mode)

**Python:**
```python
from pydantic import BaseModel

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

response = client.beta.chat.completions.parse(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Create a meeting for tomorrow"}],
    response_format=CalendarEvent
)
event = response.choices[0].message.parsed
```

**TypeScript (with Zod):**
```typescript
import { zodResponseFormat } from 'openai/helpers/zod';
import { z } from 'zod';

const CalendarEvent = z.object({
    name: z.string(),
    date: z.string(),
    participants: z.array(z.string())
});

const response = await client.beta.chat.completions.parse({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Create a meeting for tomorrow' }],
    response_format: zodResponseFormat(CalendarEvent, 'event')
});
const event = response.choices[0].message.parsed;
```

## Models

### Chat/Completion Models

| Model | Best For |
|-------|----------|
| `gpt-5.2` | Latest flagship, best quality |
| `gpt-5.2-pro` | Premium tier for complex tasks |
| `gpt-5` | Previous flagship, excellent quality |
| `gpt-5-mini` | Cost-effective GPT-5 |
| `gpt-5-nano` | Lightweight GPT-5 |
| `gpt-4.1` | Strong general purpose |
| `gpt-4.1-mini` | Cost-effective GPT-4.1 |
| `gpt-4.1-nano` | Lightweight GPT-4.1 |
| `gpt-4o` | Fast, vision support |
| `gpt-4o-mini` | Cost-effective, simpler tasks |

### Reasoning Models

| Model | Best For |
|-------|----------|
| `o4-mini` | Latest reasoning, efficient |
| `o3` | Strong reasoning |
| `o3-mini` | Reasoning with lower cost |
| `o1` | Complex reasoning, math, code |
| `o1-pro` | Premium reasoning tier |

### Specialized Models

| Model | Purpose |
|-------|---------|
| `gpt-4o-realtime-preview` | Real-time voice conversations |
| `gpt-4o-audio-preview` | Audio input/output |
| `gpt-4o-search-preview` | Web search integration |
| `gpt-image-1` / `gpt-image-1.5` | Image understanding |
| `sora-2` / `sora-2-pro` | Video generation |
| `dall-e-3` | Image generation |
| `whisper-1` | Audio transcription |
| `tts-1` / `tts-1-hd` | Text-to-speech |
| `text-embedding-3-small/large` | Text embeddings |

## Feature References

- **Advanced chat patterns**: See [references/chat-completions.md](references/chat-completions.md)
- **Image generation (DALL-E)**: See [references/images.md](references/images.md)
- **Audio (Whisper/TTS)**: See [references/audio.md](references/audio.md)
- **Embeddings**: See [references/embeddings.md](references/embeddings.md)
- **Assistants API**: See [references/assistants.md](references/assistants.md)
- **Fine-tuning**: See [references/fine-tuning.md](references/fine-tuning.md)

## Error Handling

**Python:**
```python
from openai import APIError, RateLimitError, APIConnectionError

try:
    response = client.chat.completions.create(...)
except RateLimitError:
    # Implement backoff/retry
    pass
except APIConnectionError:
    # Network issue
    pass
except APIError as e:
    print(f"API error: {e.status_code} - {e.message}")
```

**TypeScript:**
```typescript
import OpenAI from 'openai';

try {
    const response = await client.chat.completions.create({...});
} catch (error) {
    if (error instanceof OpenAI.RateLimitError) {
        // Implement backoff/retry
    } else if (error instanceof OpenAI.APIConnectionError) {
        // Network issue
    } else if (error instanceof OpenAI.APIError) {
        console.error(`API error: ${error.status} - ${error.message}`);
    }
}
```

## Common Parameters

| Parameter | Description |
|-----------|-------------|
| `temperature` | 0-2, lower = deterministic, higher = creative |
| `max_tokens` | Maximum response length |
| `top_p` | Nucleus sampling alternative to temperature |
| `stop` | Stop sequences to end generation |
| `n` | Number of completions to generate |

Related Skills

Automate YouTube Top-Ten Video Creation with OpenAI and Safe Image Search

16
from diegosouzapw/awesome-omni-skill

Integrates OpenAI API for content generation, Bing Image Search API for safe image retrieval, and Pexels API for video footage. Handles authentication via Bearer token, enforces safe search, formats ChatGPT responses into a top-ten list, and includes error handling for API failures.

using-openai-platform

16
from diegosouzapw/awesome-omni-skill

OpenAI SDK development with GPT-5 family, Chat Completions, Responses API, embeddings, and tool calling. Use for AI-powered applications, chatbots, agents, and semantic search.

openai-usage

16
from diegosouzapw/awesome-omni-skill

Report current OpenAI usage/rate-limit health from Codex ChatGPT limits.

openai-docs

16
from diegosouzapw/awesome-omni-skill

Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations (for example: Codex, Responses API, Chat Completions, Apps SDK, Agents SDK, Realtime, model capabilities or limits); prioritize OpenAI docs MCP tools and restrict any fallback browsing to official OpenAI domains.

openai-docs-skill

16
from diegosouzapw/awesome-omni-skill

Query the OpenAI developer documentation via the OpenAI Docs MCP server using CLI (curl/jq). Use whenever a task involves the OpenAI API (Responses, Chat Completions, Realtime, etc.), OpenAI SDKs, ChatGPT Apps SDK, Codex, MCP integrations, endpoint schemas, parameters, limits, or migrations and you need up-to-date official guidance.

openai-deep-research

16
from diegosouzapw/awesome-omni-skill

OpenAI Deep Research APIを使用して深層リサーチを実行するスキル。ユーザーが特定のテーマについて深層調査、市場分析、技術リサーチ等を要求する場合に使用する。

OpenAI Automation

16
from diegosouzapw/awesome-omni-skill

Automate OpenAI API operations -- generate responses with multimodal and structured output support, create embeddings, generate images, and list models via the Composio MCP integration.

chatgpt / 启用开发者模式的 / openai

16
from diegosouzapw/awesome-omni-skill

General SOP for common requests related to chatgpt, 启用开发者模式的, openai.

Build Your OpenAI Agents Skill

16
from diegosouzapw/awesome-omni-skill

Create your OpenAI Agents SDK skill in one prompt, then learn to improve it throughout the chapter

azure-ai-openai-dotnet

16
from diegosouzapw/awesome-omni-skill

Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants.

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development

moai-lang-r

16
from diegosouzapw/awesome-omni-skill

R 4.4+ best practices with testthat 3.2, lintr 3.2, and data analysis patterns.