简介
OpenAI
原始描述
Manage OpenAI files, assistants, vector stores, batches, fine-tuning jobs, and model resources via the OpenAI API. Use this skill when users want to create o...
通过你的 Agent 添加
安装目录:openai/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: openai
description: Emulated OpenAI API for local development and testing. Use when the user needs the Responses API or Chat Completions for text, streamed or not, with API keys, deterministic answers, per-key rate limits, or a count of model calls, without calling real OpenAI.
allowed-tools: Bash(npx emulate:), Bash(curl:)
OpenAI Emulator
Text-model emulation of the OpenAI API: POST /v1/responses, POST /v1/chat/completions and GET /v1/models, with deterministic answers.
Start
npx emulate --service openai
npx emulate --service openai
When all services run together, OpenAI uses http://localhost:4022.
Connect
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk-proj-emulate-default-key", baseURL: `${process.env.OPENAI_EMULATOR_URL}/v1` });
const r = await client.responses.create({ model: "gpt-5-mini", input: "Hello" });
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk-proj-emulate-default-key", baseURL: `${process.env.OPENAI_EMULATOR_URL}/v1` });
const r = await client.responses.create({ model: "gpt-5-mini", input: "Hello" });
Create more keys with POST /_emulate/openai/keys {"name":"primary"} or POST /_emulate/credentials {"type":"api-key","name":"primary"}.
Deterministic answers
# Queue the next answers exactly
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/answers/queue" -H "Content-Type: application/json" \
-d '{"answers":["First answer","Second answer"]}'
# A rule: first match wins; stream paces a streamed answer
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/answers/rules" -H "Content-Type: application/json" \
-d '{"match":{"last_user_equals":"slow"},"answer":{"text":"'"$(printf 'x%.0s' $(seq 600))"'","stream":{"chunks":600,"interval_ms":500}}}'
# Queue the next answers exactly
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/answers/queue" -H "Content-Type: application/json" \
-d '{"answers":["First answer","Second answer"]}'
# A rule: first match wins; stream paces a streamed answer
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/answers/rules" -H "Content-Type: application/json" \
-d '{"match":{"last_user_equals":"slow"},"answer":{"text":"'"$(printf 'x%.0s' $(seq 600))"'","stream":{"chunks":600,"interval_ms":500}}}'
With nothing queued and no rule, the answer is Emulated response from <model> to: <last user message>.
Limits and usage
# One key answers 429 with Retry-After; others go on
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/keys/primary/rate-limit" -H "Content-Type: application/json" \
-d '{"requests":2,"window_seconds":60}'
# Every call: key, model, approximate tokens (four characters each), streamed, request size
curl "$OPENAI_EMULATOR_URL/_emulate/openai/usage"
WebSocket endpoint
# One key answers 429 with Retry-After; others go on
curl -X POST "$OPENAI_EMULATOR_URL/_emulate/openai/keys/primary/rate-limit" -H "Content-Type: application/json" \
-d '{"requests":2,"window_seconds":60}'
# Every call: key, model, approximate tokens (four characters each), streamed, request size
curl "$OPENAI_EMULATOR_URL/_emulate/openai/usage"
An emulator control, not OpenAI's Realtime or WebSocket protocol: it echoes each message and can send messages of its own at a pace.
# Echo only; or add ?chunks=600&interval_ms=1000 for 600 messages a second apart
npx wscat -c "wss://emulators.dev/openai/<instance>/_emulate/openai/websocket?chunks=600&interval_ms=1000"
Discovery
GET /_emulate/manifest lists what is supported, partial and unsupported (tools, images, audio, embeddings, stored responses and Realtime are not emulated). GET /_emulate/ledger records each call with its operation id, status and key name; request bodies over 64 KiB are recorded by size only, and bodies over 32 MiB are refused with 413 request_too_large. Per-service docs live at https://docs.emulators.dev/openai.