xsai  by moeru-ai

Extra-small AI SDK for OpenAI or compatible APIs

Created 10 months ago
483 stars

Top 63.5% 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

3 days ago

Responsiveness

1 day

Pull Requests (30d)
9
Issues (30d)
4
Star History
57 stars in the last 30 days

Explore Similar Projects

Starred by Peter Norvig Peter Norvig(Author of "Artificial Intelligence: A Modern Approach"; Research Director at Google).

python-openai-demos by pamelafox

0.5%
381
Python scripts for OpenAI API demos
Created 1 year ago
Updated 1 week ago
Feedback? Help us improve.