@adaline/gateway

中文文档
1.15.0发布于 2026/04/23MITTypeScriptESM + CJS近 30 天下载 13.7万

Adaline Gateway

原始使用文档
文档目录10 节
  1. Features
  2. Quickstart
  3. Install packages
  4. Create a Gateway object
  5. Create a provider object
  6. Create a model object
  7. Create the config object
  8. Create the messages object
  9. Stream chat using Gateway
  10. Complete chat using Gateway

Adaline Gateway

npm bundle size npm type definitions ESLint NPM NPM version

The only fully local production-grade Super SDK that provides a simple, unified, and powerful interface for calling more than 200+ LLMs.

  • Production-ready and used by enterprises.
  • Fully local and NOT a proxy. You can deploy it anywhere.
  • Comes with batching, retries, caching, callbacks, and OpenTelemetry support.
  • Supports custom plugins for caching, logging, HTTP client, and more. You can use it like LEGOs and make it work with your infrastructure.
  • Supports plug-and-play providers. You can run fully custom providers and still leverage all the benefits of Adaline Gateway.

Features

  • 🔧 Strongly typed in TypeScript
  • 📦 Isomorphic - works everywhere
  • 🔒 100% local and private and NOT a proxy
  • 🛠️ Tool calling support across all compatible LLMs
  • 📊 Batching for all requests with custom queue support
  • 🔄 Automatic retries with exponential backoff
  • ⏳ Caching with custom cache plug-in support
  • 📞 Callbacks for full custom instrumentation and hooks
  • 🔍 OpenTelemetry to plug tracing into your existing infrastructure
  • 🔌 Plug-and-play custom providers for local and custom models

Quickstart

Install packages

npm install @adaline/gateway @adaline/types @adaline/openai @adaline/anthropic 

Create a Gateway object

Gateway object maintains the queue, cache, callbacks, implements OpenTelemetry, etc. You should use the same Gateway object everywhere to get the benefits of all the features.

import { Gateway } from "@adaline/gateway";

const gateway = new Gateway();

Create a provider object

Provider object stores the types/information about all the models within that provider. It exposes the list of all the chat openai.chatModelLiterals() and embedding openai.embeddingModelLiterals() models.

import { Anthropic } from "@adaline/anthropic";
import { OpenAI } from "@adaline/openai";

const openai = new OpenAI();
const anthropic = new Anthropic();

Create a model object

Model object enforces the types from roles, to config, to different modalities that are supported by that model. You can also provide other keys like baseUrl, organization, etc.

Model object also exposes functions:

  • transformModelRequest that takes a request formatted for the provider and converts it into the Adaline super-types.
  • getStreamChatData that is then used to compose other provider calls. For example, calling an Anthropic model from Bedrock.
  • and many more to enable deep composability and provide runtime validations.
const gpt4o = openai.chatModel({
  modelName: "gpt-4o",
  apiKey: "your-api-key",
});

const haiku = anthropic.chatModel({
  modelName: "claude-3-haiku-20240307",
  apiKey: "your-api-key",
});

Create the config object

Config object provides type checks and also accepts generics that can be used to add max, min, and other validation checks per model.

import { Config } from "@adaline/types";

const config = Config().parse({
  maxTokens: 200,
  temperature: 0.9,
});

Create the messages object

Message object is the Adaline super-type that supports all the roles and modalities across 200+ LLMs.

import { MessageType } from "@adaline/types";

const messages: MessageType[] = [
  {
    role: "system",
    content: [{
      modality: "text",
      value: "You are a helpful assistant. You are extremely concise.
    }],
  },
  {
    role: "user",
    content: [{
      modality: "text",
      value: `What is ${Math.floor(Math.random() * 100) + 1} + ${Math.floor(Math.random() * 100) + 1}?`,
    }],
  },
];

Stream chat using Gateway

await gateway.streamChat({
  model: gpt4o,
  config: config,
  messages: messages,
});

Complete chat using Gateway

await gateway.completeChat({
  model: haiku,
  config: config,
  messages: messages,
});

版本与发布记录

@adaline/gateway 共发布 54 个版本,首次发布于 2024/09/03;过去 12 个月发布了 8 个版本。

版本发布日期距今
1.15.0latest2026/04/236 个月前
1.14.12026/04/106 个月前
1.14.02026/04/066 个月前
1.13.12026/03/038 个月前
1.13.02026/02/078 个月前
1.12.02026/01/159 个月前

关于 @adaline/gateway 的常见问题

@adaline/gateway 是什么?

Adaline Gateway

如何安装 @adaline/gateway?

在项目目录运行 npm install @adaline/gateway,或使用 pnpm add / yarn add / bun add。

@adaline/gateway 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adaline/gateway 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@adaline/gateway 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adaline/gateway 可以商用吗?

@adaline/gateway 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adaline/gateway 的下载量有多少?

根据 npm 官方下载统计,@adaline/gateway 在 2026/10/05 – 2026/11/03 这 30 天内被下载 137,083 次,日均约 4,569 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adaline/gateway 还在维护吗?

最新版本 1.15.0 发布于 2026/04/23(6 个月前);至今共发布 54 个版本,其中过去 12 个月发布了 8 个;首次发布于 2024/09/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。