Agent Skills
› moeru-ai/apeira
› xsai
xsai
GitHub适用于 xsAI 及 @xsai/* 包的开发辅助,支持 OpenAI 兼容接口的文本生成、流式处理、工具调用等。强调轻量级、最小依赖原则,指导包选择、代码示例编写及配置规范。
Trigger Scenarios
用户正在使用或评估 xsAI 及其子包
需要构建基于 OpenAI 兼容 API 的轻量级 AI 工作流
比较 xsAI 与其他大型 SDK 的权衡
Install
npx skills add moeru-ai/apeira --skill xsai -g -y
SKILL.md
Frontmatter
{
"name": "xsai",
"description": "Use this skill when the user is building with `xsai` or any `@xsai\/*` package, or is evaluating xsAI for a small OpenAI-compatible workflow with text generation, streaming, tool calling, structured output, embeddings, image generation, speech synthesis, or transcription."
}
xsAI
Use this skill for xsai code, package selection, API selection, canonical examples, and positioning.
Use xsAI when
- The user is already using
xsaior any@xsai/*package. - The user is evaluating xsAI for an OpenAI-compatible integration.
- The target API is OpenAI-compatible.
- The user wants a small runtime or package footprint.
- The user needs text generation, streaming, structured output, or tool calling without a broad framework.
- The user is comparing
xsaiwith larger SDKs such asaiorpiand wants the tradeoffs framed clearly.
Do not use xsAI when
- The user needs a universal provider abstraction beyond OpenAI-compatible APIs.
- The user wants a batteries-included AI application framework.
- The task depends on provider-specific APIs that are not exposed through an OpenAI-compatible surface.
Default workflow
- First inspect the existing dependency and import style in the repo. Preserve
xsaiversus granular@xsai/*imports unless the user asks to change them. - If the user has not chosen xsAI yet, confirm the task fits an OpenAI-compatible surface before recommending it.
- Prefer the smallest package that solves the task. Use the umbrella
xsaipackage only when the user needs several features at once or explicitly wants one dependency. - When writing or editing code, read
references/recipes.mdfirst and start from the closest canonical example. - Keep examples minimal and runnable. Include
baseURLandmodelexplicitly. For hosted providers, showapiKeywired fromprocess.envin Node.js and fromlocalStoragein the browser; omit it only when the target endpoint truly does not need one. Do not recommend hardcoding secrets. - Preserve the project's existing schema library and provider wiring unless there is a clear reason to change them.
- Keep recommendations aligned with xsAI's scope: OpenAI-compatible, Fetch-based, runtime-portable, and intentionally narrow.
- If the user is optimizing for bundle or install size, explicitly prefer granular packages such as
@xsai/generate-textoverxsai. - If the user asks for broader provider abstraction, say xsAI intentionally does not optimize for that.
References
- Read
references/recipes.mdwhen the user wants code, edits xsAI code, or needs a canonical minimal example. - Read
references/package-selection.mdwhen the user needs help choosing betweenxsaiand granular packages. - Read
references/text-stream-tools.mdforgenerateText,streamText, tool calling, and common chat options. - Read
references/structured-output.mdforgenerateObject,streamObject,tool(),rawTool(), or schema guidance. - Read
references/media-and-embeddings.mdfor embeddings, image generation, speech, or transcription. - Read
references/extensions.mdonly when the user explicitly needs xsAI extensions such as predefined providers, the OpenAI Responses API, or OTEL telemetry.
API selection rules
- Use
generateTextfor unary text generation. - Use
streamTextfor incremental text, reasoning deltas, tool events, or lightweight agent loops. - Use
generateObjectfor validated structured output. - Use
streamObjectwhen the user needs incremental object parsing. - Use
tool()when the user has a Standard Schema library such as Zod or Valibot. - Use
rawTool()when the user already has raw JSON Schema. - Use a plain
Toolobject only when the repo already uses that shape or when avoidingtool()'s async setup matters.
Key constraints
baseURLandmodelare usually required in practice for xsAI calls.apiKeyis provider-dependent. Most hosted providers need it; local or proxy endpoints may not. In Node.js, preferprocess.env. In browsers, prefer reading fromlocalStorage. Do not recommend hardcoding API keys.- xsAI is OpenAI-compatible-first. Do not imply support for non-compatible provider APIs.
streamText()returns immediately; callers consumetextStream,fullStream, and result promises asynchronously.streamObject()is async because schema conversion happens before streaming starts.stopWhencontrols repeated tool-use loops with explicit stop predicates such asstepCountAtLeast()andhasToolCall().generateObject(),streamObject(), andtool()rely onxsschema; some schema vendors need extra JSON Schema converter packages.- xsAI is designed to stay small. Avoid recommending the umbrella package when a smaller package is enough.
Positioning
- Describe xsAI as an extra-small OpenAI-compatible runtime, not as a universal AI SDK.
- When comparing with
aiorpi, focus on size, runtime portability, OpenAI-compatible scope, and simpler primitives. Do not oversell feature breadth.
Docs
- Public docs:
https://xsai.js.org/docs
Version History
- c95e8c3 Current 2026-07-05 11:02


