xsai  by moeru-ai

Extra-small AI SDK for OpenAI or compatible APIs

created 8 months ago
417 stars

Top 71.3% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

xsAI is a lightweight, runtime-agnostic SDK for interacting with OpenAI and OpenAI-compatible APIs, designed for developers prioritizing minimal bundle sizes and broad compatibility across environments like browsers, Deno, Bun, and Edge. It offers core functionalities for text generation and streaming, with extensions for tool calling and structured output.

How It Works

xsAI achieves its small footprint by acting as a thin wrapper around the Fetch API, utilizing ESM-only modules, and selectively adding dependencies only when necessary for advanced features like tool calls. This approach minimizes overhead and ensures compatibility across various JavaScript runtimes without relying on Node.js built-ins.

Quick Start & Requirements

  • Install: npm install xsai (or yarn add xsai, pnpm install xsai, bun install xsai, deno install xsai)
  • Prerequisites: OpenAI API key.
  • Documentation: https://github.com/moeru-ai/xsai

Highlighted Details

  • Core @xsai/generate-text package is 1.4KB gzipped.
  • Supports streaming responses via @xsai/stream-text.
  • Includes tool calling and structured output capabilities using Valibot for parameter validation.
  • Runtime-agnostic, working in browsers, Deno, Bun, and Edge environments.

Maintenance & Community

The project is part of the moeru-ai organization, which also maintains projects like airi and arpk. Other community projects integrating or related to xsAI are listed.

Licensing & Compatibility

  • License: MIT
  • Compatibility: Compatible with commercial and closed-source applications. xsAI is not affiliated with OpenAI.

Limitations & Caveats

The project is in an early stage of development and may introduce breaking changes.

Health Check
Last commit

18 hours ago

Responsiveness

1 day

Pull Requests (30d)
23
Issues (30d)
12
Star History
82 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.