> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Node.js SDK Overview

> Getting started with the MeshAPI Node.js SDK.

# Node.js SDK

TypeScript SDK for the **MeshAPI** AI model gateway — an OpenAI-compatible API that proxies to OpenRouter with multi-tenant key management, rate limiting, and prompt templates.

Supports **Node.js 18+** with full TypeScript strict-mode types, native `fetch`, and streaming via `AsyncIterable`.

## Installation

```bash
npm install meshapi-node-sdk
# or
pnpm add meshapi-node-sdk
# or
yarn add meshapi-node-sdk
```

## Quick Start

```ts
import { MeshAPI } from "meshapi-node-sdk";

const client = new MeshAPI({
  baseUrl: "https://api.yourdomain.com",
  token: "rsk_01JXXXXXXXXXXXXXXXXXXXXXXXXX", // data-plane API key
});
```

## Authentication

All requests require a Mesh API key (prefixed with `rsk_`).

```ts
const client = new MeshAPI({
  baseUrl: "https://api.yourdomain.com",
  token: "rsk_01JXXXXXXXXXXXXXXXXXXXXXXXXX",
});
```

This key provides access to all endpoints, including completions, models, templates, images, and batch jobs.

## Configuration Options

```ts
const client = new MeshAPI({
  baseUrl: "https://api.yourdomain.com",  // required
  token: "rsk_...",                        // required
  timeoutMs: 30_000,                       // default: 60_000 (60s)
  signal: myAbortController.signal,        // optional global AbortSignal
  fetch: customFetch,                      // optional fetch override (for mocking/polyfills)
});
```

## TypeScript

The SDK ships full `.d.ts` declarations. Key types:

```ts
import type {
  ChatCompletionParams,
  ChatCompletionResponse,
  ChatCompletionChunk,
  ChatMessage,
  ModelInfo,
  TemplateSummary,
  CreateTemplateParams,
  MeshAPIConfig,
} from "meshapi-node-sdk";
```