- Category
- AI Tools
- Rank
- No. 746Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- moeru-ai
- GitHub
- 655 stars
- Latest release
- v0.5.0
- Date
About
Extra-small AI SDK for TypeScript. Minimal, OpenAI- and Ollama-compatible client for building LLM apps without bundling the world.
What it does
xsAI sends model requests through standard web APIs and returns text, streams, structured data, embeddings, images, or speech. Its chat flow can execute declared tools across multiple steps, track token usage, expose reasoning output, and stop under caller-defined conditions. Separate packages let applications include only the capabilities they need.
Why it's ranked here
xsAI is a compelling focused choice because its small footprint follows from concrete design decisions: direct Fetch API use, ESM packaging, selective dependencies, and separately installable capabilities. It still covers streaming, tool execution, usage accounting, structured output, and several media types. That is substantial utility without adopting a broad application framework.
What's good
The streaming layer exposes text, reasoning, raw chunks, events, messages, steps, and usage through distinct streams or promises. Tool calls can continue across steps, execute concurrently, and feed results back into the conversation. Abort signals, lifecycle hooks, customizable fetching, and per-step preparation give callers useful control without forcing a provider abstraction.
Tradeoffs
The project deliberately offers no universal provider abstraction and does not attempt to manage an entire AI application. ESM-only packaging may exclude older module setups. Its portability depends on modern web primitives such as readable streams, transform streams, structured cloning, and promise resolvers. Image generation and streamed speech are explicitly marked experimental in the supplied source.
How to use it well
Pick xsAI for TypeScript applications that already know their compatible endpoint and want direct control over prompts, tools, streaming, and request options. Install a narrow capability package when bundle size matters, or the aggregate package for convenience. Bring separate infrastructure for provider routing, application orchestration, persistence, evaluation, observability, and user-interface concerns.
Technical notes+
The root package.json defines a private ESM pnpm workspace built with Turbo, TypeScript, and package-level tests. packages/generate-text/src/index.ts implements generateText through chat, responseJSON, usage normalization, stop conditions, concurrent tool execution, and a trampoline for repeated steps. packages/stream-text/src/index.ts parses server-sent events into raw, event, text, and reasoning streams while resolving messages, steps, and usage promises. packages/generate-image/src/index.ts normalizes Base64 and URL responses into data URLs, while packages/stream-speech/src/index.ts decodes streamed Base64 audio bytes and usage events. packages/embed/src/index.ts and packages/tool/src/index.ts expose dedicated embedding and tool surfaces.
Observed
- License
- MIT
- Primary language
- TypeScript
- Interface
- ESM library SDK
- Packaging
- Private pnpm monorepo with an aggregate package and separately installable capability packages
- Install surface
- Documented installation through npm, Yarn, pnpm, Bun, and Deno
- Runtime support
- Browsers, Deno, Bun, and edge runtimes; no Node.js built-in module dependency
- Request foundation
- Built directly on the Fetch API
- Capability surface
- Text generation and streaming, structured data, embeddings, tools, image generation, and speech streaming
Read from README.md, package.json, packages/tool/src/index.ts, packages/embed/src/index.ts, packages/model/src/index.ts, packages/shared/src/index.ts, packages/utils-chat/src/index.ts, packages/shared-chat/src/index.ts, packages/stream-text/src/index.ts, packages/utils-stream/src/index.ts, packages/generate-text/src/index.ts, packages/shared-stream/src/index.ts, packages/stream-object/src/index.ts, packages/stream-speech/src/index.ts, packages/generate-image/src/index.ts.
What it can do
Connect to OpenAI API
API credentials and configuration → Established connection to OpenAI services
Connect to Ollama API
Ollama server endpoint and configuration → Established connection to Ollama services
Generate text responses from LLM
Text prompts and model parameters → AI-generated text responses
Build lightweight TypeScript LLM applications
TypeScript code and AI model requirements → Compiled LLM application with minimal dependencies
Send requests to language models
Formatted API requests with prompts → Structured API responses from LLM services
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.
