moeru-ai/xsai
🤖💬 AI SDK, extra small.
What it solves
xsAI addresses the bloat and provider-lock-in common in AI SDKs. It provides a lightweight, modular way to interact with various AI models without forcing developers to use heavy libraries or tie their code to a specific provider's API.
How it works
Instead of creating a separate package for every AI provider, xsAI uses a protocol-based approach. It provides adapters for common protocols (like OpenAI Responses, Chat Completions, and Anthropic Messages). Because these adapters all return a consistent LanguageModel type, developers can switch between different services that use the same protocol without changing their core application logic. The SDK is built entirely on web standards (fetch, ReadableStream, AbortSignal, and FormData), making it compatible with any runtime that supports these standards, including browsers, Node.js, Deno, Bun, and Cloudflare Workers.
Who it’s for
It is designed for developers who want a minimal, type-safe AI SDK that is easy to bundle, avoids unnecessary dependencies, and remains flexible across different AI service providers.
Highlights
- Modular Architecture: Each package has a single responsibility, allowing bundlers to remove unused code.
- Protocol-Centric: One adapter covers all services speaking the same protocol, decoupling the code from the provider.
- Web Standard Based: No Node.js-specific modules are used, ensuring maximum runtime compatibility.
- End-to-End Typing: Full TypeScript support for options, results, and events, with schema validation following the Standard Schema specification.
- Broad Capability: Includes specialized packages for text generation, audio (speech/transcription), embeddings, image generation, and decision-making.
Related
- Project
- Project
- Dispatch
- Project
- Project