For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI ReferenceSDKs
DocsAPI ReferenceSDKs
      • Overview
      • Chat Completions
      • Prompt Templates
      • Files & Batches
      • Embeddings
      • Image Generation
      • Responses (Reasoning)
      • Compare (Multi-model)
      • Models
      • Error Handling
LogoLogo
On this page
  • Node.js SDK
  • Installation
  • Quick Start
  • Authentication
  • Configuration Options
  • TypeScript
Node.js SDK

Node.js SDK Overview

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Error Handling

Next

Chat Completions

Built with

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

$npm install meshapi-node-sdk
$# or
$pnpm add meshapi-node-sdk
$# or
$yarn add meshapi-node-sdk

Quick Start

1import { MeshAPI } from "meshapi-node-sdk";
2
3const client = new MeshAPI({
4 baseUrl: "https://api.yourdomain.com",
5 token: "rsk_01JXXXXXXXXXXXXXXXXXXXXXXXXX", // data-plane API key
6});

Authentication

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

1const client = new MeshAPI({
2 baseUrl: "https://api.yourdomain.com",
3 token: "rsk_01JXXXXXXXXXXXXXXXXXXXXXXXXX",
4});

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

Configuration Options

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

TypeScript

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

1import type {
2 ChatCompletionParams,
3 ChatCompletionResponse,
4 ChatCompletionChunk,
5 ChatMessage,
6 ModelInfo,
7 TemplateSummary,
8 CreateTemplateParams,
9 MeshAPIConfig,
10} from "meshapi-node-sdk";