Node.js SDK
Node.js SDK
The MeshAPI Node.js SDK provides a robust, native-fetch TypeScript client. It includes strict-mode typings, AsyncIterable streaming support, and comprehensive error handling.
Requirements
- Node.js ≥ 18
- Zero runtime dependencies
Installation
npm
yarn
pnpm
Quick Start
Initialize MeshAPI providing your Base URL and Data-Plane token.
Standard Chat Completion
Streaming Chat Completion
Streaming utilizes native JavaScript async iterators (for await).
Error Handling
All API errors throw a MeshAPIApiError with structured fields for deterministic failure handling. Mid-stream errors (e.g., interrupted stream before [DONE]) are also reliably caught and bubbled up as MeshAPIApiErrors.
Prompt Templates
You can pass a Template ID instead of messages directly to utilize saved prompt templates.