Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计异常

openai-apiOpenAI API 控制

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

428

周安装

18

GitHub Stars

公开资料未说明

下载量

150
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:openai-api(OpenAI API 控制)
来源仓库:https://github.com/diskd-ai/openai-api
仓库路径:skills/openai-api
安装命令:
npx skills add https://github.com/diskd-ai/openai-api --skill openai-api
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/diskd-ai/openai-api --skill openai-api

简介

openai-api 集成 OpenAI 官方 SDK,支持 Chat Completions、Embeddings 与 Image Generation 等服务。

  • 提供 Python 与 TypeScript 双版本示例,涵盖流式输出与函数调用等高级特性。
  • 强调环境变量安全管理,禁止硬编码密钥于代码库中。
  • 实际部署时应根据业务需求选择合适模型版本,并设置超时与重试机制保障稳定性。
  • openai-api 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

OpenAI API

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

Quick Start

Installation

# Python
pip install openai

# TypeScript/Node.js
npm install openai

Client Setup

Python:

from openai import OpenAI

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

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:

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:

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:

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:

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:

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:

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:

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:

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):

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

ModelBest For
gpt-5.2Latest flagship, best quality
gpt-5.2-proPremium tier for complex tasks
gpt-5Previous flagship, excellent quality
gpt-5-miniCost-effective GPT-5
gpt-5-nanoLightweight GPT-5
gpt-4.1Strong general purpose
gpt-4.1-miniCost-effective GPT-4.1
gpt-4.1-nanoLightweight GPT-4.1
gpt-4oFast, vision support
gpt-4o-miniCost-effective, simpler tasks

Reasoning Models

ModelBest For
o4-miniLatest reasoning, efficient
o3Strong reasoning
o3-miniReasoning with lower cost
o1Complex reasoning, math, code
o1-proPremium reasoning tier

Specialized Models

ModelPurpose
gpt-4o-realtime-previewReal-time voice conversations
gpt-4o-audio-previewAudio input/output
gpt-4o-search-previewWeb search integration
gpt-image-1 / gpt-image-1.5Image understanding
sora-2 / sora-2-proVideo generation
dall-e-3Image generation
whisper-1Audio transcription
tts-1 / tts-1-hdText-to-speech
text-embedding-3-small/largeText embeddings

Feature References

Error Handling

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:

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

ParameterDescription
temperature0-2, lower = deterministic, higher = creative
max_tokensMaximum response length
top_pNucleus sampling alternative to temperature
stopStop sequences to end generation
nNumber of completions to generate

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.44%
按下载量换算43

Codex

26.03%
按下载量换算39

OpenCode

17.8%
按下载量换算27

Antigravity

14.41%
按下载量换算22

Gemini CLI

8.13%
按下载量换算12

Cursor

3.4%
按下载量换算5

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

未通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills