gateway

adalineMIT活跃维护

一个完全本地部署的生产级 Super SDK,用统一接口调用 200 多个大模型,省去为每家厂商单独适配的麻烦。

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

v1.12.1发布于 2026-07-29 19:11 UTC607star27fork同步于 2026-11-07 07:29 UTC

怎么上手

由 README 提炼,执行前请确认
npm install @adaline/gateway @adaline/types
硬件要求按 README 说明

README 未说明,纯本地 SDK,模型推理在远端提供商或自定义 provider 侧完成

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

本地运行的统一 LLM SDK,用一个接口调用 300+ 模型,不用自建代理

一个完全本地部署的生产级 Super SDK,用统一接口调用 200 多个大模型,省去为每家厂商单独适配的麻烦。

核心能力

  • 统一 TypeScript 接口调用 300+ LLM 与嵌入模型
  • 内置批处理队列、指数退避重试与缓存
  • 支持工具调用,跨兼容模型统一消息与配置类型
  • 通过插件自定义缓存、日志与 HTTP 客户端
  • 集成 OpenTelemetry 与回调做可观测性

容易踩的坑

各 provider 包是可选依赖,需按需单独安装如 @adaline/openai;调用时需自备对应厂商的 API Key;ConfigType 中未知字段会被静默忽略,写错参数名不会报错

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.12.1
  1. v1.12.1最新正式版2026-07-29 · 2026-07-29 19:11 UTC

    Bug Fixes

    • chore: remove retired models, add latest, fix drift by Akshay Gulati 173dbff
  2. v1.12.02026-07-11 · 2026-07-11 05:25 UTC
    查看更新说明

    Breaking

    • feat(openai): add gpt-5.6 family with xhigh reasoning effort and reasoning mode by Akshay Gulati a1cec5b

    Features

    • feat: sync latest provider models by Akshay Gulati 11dfa99
    • feat(xai): add grok-4.5, grok-4.3, grok-4.20 family, and grok-build-0.1 by Akshay Gulati e8e1c41
    • feat(groq): add qwen3.6-27b and llama-prompt-guard-2 models by Akshay Gulati fb4d3cd
    • feat(azure): add gpt-5.4 family, gpt-5.5, gpt-5.6 family, gpt-5-pro, o3-pro wrappers by Akshay Gulati b0bd424
    • feat(bedrock): add claude-sonnet-5 and claude-opus-4-8; fix opus-4-7/sonnet-4-6 IDs by Akshay Gulati c323ea2
    • feat(vertex): add gemini-3.5-flash and gemini-3.1-flash-lite by Akshay Gulati d806d09
    • feat(anthropic): add claude-sonnet-5 by Akshay Gulati 25defb1

    Bug Fixes

    • feat(bedrock): add claude-sonnet-5 and claude-opus-4-8; fix opus-4-7/sonnet-4-6 IDs by Akshay Gulati c323ea2
    • fix(google): correct gemini-2.5-pro tiered pricing and gemini-embedding-2 price by Akshay Gulati c04c438
  3. v1.11.262026-06-09 · 2026-06-09 23:08 UTC
    查看更新说明

    Features

    • feat: sync latest LLMs by Akshay Gulati 28355f9
  4. v1.11.252026-06-08 · 2026-06-08 19:18 UTC
    查看更新说明
  5. v1.11.242026-06-08 · 2026-06-08 13:37 UTC
    查看更新说明

    Features

    • feat: add support for gemini-embedding-2, gemini-embedding-001, voyage-4 family by Ankit Prasad 249e92c

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Adaline Gateway

    npm npm npm bundle size License

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

    • Production-ready and trusted by enterprises
    • Fully local and NOT a proxy - deploy it anywhere
    • Built-in batching, retries, caching, callbacks, and OpenTelemetry support
    • Extensible with custom plugins for caching, logging, HTTP clients, and more - use it like building blocks to integrate with your infrastructure
    • Supports plug-and-play providers - run fully custom providers while leveraging all the benefits of Adaline Gateway

    Features

    • 🔧 Strongly typed in TypeScript
    • 📦 Isomorphic - works everywhere
    • 🔒 100% local, 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 comprehensive instrumentation and hooks
    • 🔍 OpenTelemetry integration for existing infrastructure
    • 🔌 Plug-and-play custom providers for local and custom models

    Providers

    ProviderChat ModelsEmbedding Models
    OpenAI✅✅
    Anthropic✅❌
    Google AI Studio✅❌
    Google Vertex✅✅
    xAi✅✅
    AWS Bedrock✅❌
    Azure OpenAI✅✅
    Groq✅❌
    Together AI✅❌
    Open Router✅❌
    Custom (OpenAI-like)✅❌
    Voyage❌✅

    Installation

    Core packages

    npm install @adaline/gateway @adaline/types
    

    Provider packages

    Dependencies for providers are optional. You can install them as needed. For example:

    npm install @adaline/openai @adaline/anthropic @adaline/google @adaline/open-router @adaline/bedrock
    

    Quickstart

    Chat

    This example demonstrates how to invoke an LLM with a simple text prompt in both non-streaming and streaming modes.

    import { Gateway } from "@adaline/gateway";
    import { OpenAI } from "@adaline/openai";
    import { Config, ConfigType, MessageType } from "@adaline/types";
    
    const OPENAI_API_KEY = "your-api-key"; // Replace with your OpenAI API key
    
    const gateway = new Gateway();
    const openai = new OpenAI();
    
    const gpt4o = openai.chatModel({
      modelName: "gpt-4o",
      apiKey: OPENAI_API_KEY,
    });
    
    const config: ConfigType = Config().parse({
      temperature: 0.7,
      maxTokens: 300,
    });
    
    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}?`,
        }],
      },
    ];
    
    // * Complete chat
    async function runCompleteChat() {
      const completeChat = await gateway.completeChat({
        model: gpt4o,
        config,
        messages,
        tools: [],
      });
      console.log(completeChat.provider.request); // HTTP Request sent to Provider
      console.log(completeChat.provider.response); // HTTP Response from Provider
      console.log(completeChat.cached); // Whether the response was cached
      console.log(completeChat.latencyInMs); // Latency in milliseconds
      console.log(completeChat.request); // Request in Gateway types
      console.log(completeChat.response); // Response in Gateway types, E.g.:
      // {
      //   "messages": [
      //     {
      //       "role": "assistant",
      //       "content": [
      //         {
      //           "modality": "text",
      //           "value": "<some-text-returned-by-LLM>"
      //         }
      //       ]
      //     }
      //   ],
      //   "usage": {
      //     "promptTokens": 138,
      //     "completionTokens": 573,
      //     "totalTokens": 711
      //   },
      //   "logProbs": []
      // }
      //
    }
    
    runCompleteChat();
    
    // * Stream chat
    async function runStreamChat() {
      const streamChat = await gateway.streamChat({
        model: gpt4o,
        config,
        messages,
        tools: [],
      });
    
      for await (const chunk of streamChat) {
        console.log(chunk.response);
      }
    }
    
    runStreamChat();
    

    Word Embedding

    This example demonstrates how to invoke an embedding model with text samples to generate word embeddings.

    import { Gateway } from "@adaline/gateway";
    import { OpenAI } from "@adaline/openai";
    import { Config, ConfigType, EmbeddingRequestsType } from "@adaline/types";
    
    const OPENAI_API_KEY = "your-api-key"; // Replace with your OpenAI API key
    
    const gateway = new Gateway();
    const openai = new OpenAI();
    
    const textEmbedding3Large = openai.embeddingModel({
      modelName: "text-embedding-3-large",
      apiKey: OPENAI_API_KEY,
    });
    
    const config: ConfigType = Config().parse({
      encodingFormat: "float",
      dimensions: 255,
    });
    
      const embeddingRequests: EmbeddingRequestsType = {
        modality: "text",
        requests: [
          "Hello world",
          "When the going gets tough, the tough get going. Or the tough pivots",
        ],
      };
    
    async function runWordEmbedding() {
      const wordEmbedding = await gateway.getEmbeddings({
        model: textEmbedding3Large,
        config,
        embeddingRequests,
      });
      console.log(wordEmbedding.response);
    }
    
    runWordEmbedding();
    

    List Supported Models

    import { OpenAI } from "@adaline/openai";
    
    const openai = new OpenAI();
    
    const openaiChatModels = openai.chatModelLiterals();
    console.log(openaiChatModels); // Array of chat model names
    
    const openaiEmbeddingModels = openai.embeddingModelLiterals();
    console.log(openaiEmbeddingModels); // Array of embedding model names
    
    const o4MiniSchema = openai.chatModelSchemas()["o4-mini"]; // Schema for the o4-mini chat model
    console.log(o4MiniSchema.name);
    console.log(o4MiniSchema.description);
    console.log(o4MiniSchema.maxInputTokens);
    console.log(o4MiniSchema.maxOutputTokens);
    console.log(o4MiniSchema.roles);
    console.log(o4MiniSchema.modalities);
    console.log(o4MiniSchema.config); 
    

    Prompt Types

    @adaline/types contains the core types used to build prompts and process LLM responses.

    Config

    A ConfigType is used to configure parameters of an LLM for a request. The valid fields for ConfigType depend on the specific LLM being used. Refer to the documentation of the LLM provider for details. Gateway internally transforms the ConfigType to and from the LLM provider's schema.

    Note: ConfigType is a lenient and forgiving type; any unknown fields will be ignored during transformation.

    // Example of a config
    const config: ConfigType = Config().parse({
      temperature: 0.7,
      maxTokens: 1000,
      // Any unknown fields will be ignored
      unknownField: "This will be ignored"
    });
    

    The exact schema for ConfigType for each LLM can be found programmatically using the provider's SDK:

    import { OpenAI } from "@adaline/openai";
    
    const openai = new OpenAI();
    
    const o4MiniSchema = openai.chatModelSchemas()["o4-mini"];
    console.log(o4MiniSchema.config.def); // Verbose description of the Config for this LLM
    console.log(o4MiniSchema.config.schema); // Zod type to validate Config for this LLM
    

    Message

    A MessageType is the core component of a prompt sent to the LLM provider and the response received from it. Gateway internally transforms the MessageType to and from the LLM provider's schema.

    FieldTypeDescriptionConstraints
    roleRoleEnumTypeThe role of the message senderMust be one of the defined roles
    contentArrayArray of content itemsMust contain at least one content item
    // Example of a message
    const message: MessageType = {
      role: "system",
      content: [
        {
          modality: "text",
          value: "Hello, how can I help you today?",
        }
      ]
    };
    
    // Example of a message
    const completeMessage: MessageType = {
      role: "assistant",
      content: [
        {
          modality: "text",
          value: "I've analyzed the image you sent and found the following information:",
        },
        {
          modality: "reasoning",
          value: {
            type: "thinking",
            thinking: "The image appears to contain a chart with quarterly sales data. I should point out the key trends.",
            signature: "reasoning-signature-456"
          },
        },
        {
          modality: "tool-call",
          index: 0,
          id: "call_987654321",
          name: "analyze_chart",
          arguments: '{"chart_type": "bar", "data_points": ["Q1", "Q2", "Q3", "Q4"]}',
        }
      ],
    };
    
    Role

    A RoleEnumType is an enumeration of possible message roles. Gateway internally transforms these roles to and from the LLM provider's accepted roles. For example, the "assistant" role in Gateway will be transformed to the "model" role for Google's Gemini models.

    ValueDescription
    systemMessages from the system
    userMessages from the user
    assistantMessages from the assistant
    toolMessages from a tool
    // Example of a role
    const role: RoleEnumType = "assistant";
    
    Content

    A ContentType is the core part of a message that contains the actual content (text, images, etc.) being sent to or received from the LLM provider.

    Text Content

    A TextContentType represents text content in a message being sent to or received from the LLM provider.

    FieldTypeDescriptionConstraints
    modality"text"Indicates this is text contentMust be "text"
    valuestringThe text contentAny valid string
    // Example of text content
    const textContent: TextContentType = {
      modality: "text",
      value: "Hello, how can I help you today?"
    };
    
    Image Content

    An ImageContentType represents image content in a message being sent to or received from the LLM provider.

    FieldTypeDescriptionConstraints
    modality"image"Indicates this is image contentMust be "image"
    detailImageContentDetailsLiteralTypeThe level of detail for processing the imageMust be "low", "medium", "high", or "auto"
    valueImageContentValueTypeThe image dataMust be either Base64 or URL type
    // Example of base64 image content
    const base64ImageContent: ImageContentType = {
      modality: "image",
      detail: "high",
      value: {
        type: "base64",
        base64: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
        mediaType: "png"
      },
    };
    
    // Example of URL image content
    const urlImageContent: ImageContentType = {
      modality: "image",
      detail: "medium",
      value: {
        type: "url",
        url: "https://example.com/image.jpg"
      },
    };
    

    The value field can be one of two types:

    Base64ImageContentValueType:

    FieldTypeDescriptionConstraints
    type"base64"Indicates base64 encodingMust be "base64"
    base64stringBase64-encoded image dataValid base64 string
    mediaType"png" | "jpeg" | "webp" | "gif"The image formatMust be one of the specified formats
    // Example of base64 image content value
    const base64ImageContent: Base64ImageContentValueType = {
      type: "base64",
      base64: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",
      mediaType: "png"
    };
    

    UrlImageContentValueType:

    FieldTypeDescriptionConstraints
    type"url"Indicates URL referenceMust be "url"
    urlstringURL pointing to the imageValid URL string
    // Example of URL image content value
    const urlImageContent: UrlImageContentValueType = {
      type: "url",
      url: "https://example.com/image.png"
    };
    
    Tool Call Content

    A ToolCallContentType represents a tool call in a message being sent to or received from the LLM provider.

    FieldTypeDescriptionConstraints
    modality"tool-call"Indicates this is a tool callMust be "tool-call"
    indexnumberThe index of the tool callNon-negative integer
    idstringUnique identifier for the tool callNon-empty string
    namestringName of the tool being calledNon-empty string
    argumentsstringArguments passed to the toolAny valid string
    // Example of tool call content
    const toolCallContent: ToolCallContentType = {
      modality: "tool-call",
      index: 0,
      id: "call_123456789",
      name: "search_database",
      arguments: '{"query": "user information", "limit": 10}',
    };
    
    Tool Response Content

    A ToolResponseContentType represents a tool response in a message being sent to or received from the LLM provider.

    FieldTypeDescriptionConstraints
    modality"tool-response"Indicates this is a tool responseMust be "tool-response"
    indexnumberThe index of the tool responseNon-negative integer
    idstringUnique identifier for the tool callNon-empty string
    namestringName of the tool that was calledNon-empty string
    datastringResponse data from the toolAny valid string
    // Example of tool response content
    const toolResponseContent: ToolResponseContentType = {
      modality: "tool-response",
      index: 0,
      id: "call_123456789",
      name: "search_database",
      data: '{"results": [{"id": 1, "name": "John Doe"}, {"id": 2, "name": "Jane Smith"}]}',
    };
    
    Reasoning Content

    A ReasoningContentType represents reasoning content in a message being sent to or received from the LLM provider.

    FieldTypeDescriptionConstraints
    modality"reasoning"Indicates this is reasoning contentMust be "reasoning"
    valueReasoningContentValueUnionTypeThe reasoning contentMust be a valid reasoning value type
    // Example of reasoning content
    const reasoningContent: ReasoningContentType = {
      modality: "reasoning",
      value: {
        type: "thinking",
        thinking: "I need to consider the user's request carefully...",
        signature: "reasoning-signature-123"
      },
      metadata: undefined
    };
    
    // Example of redacted reasoning content
    const redactedReasoningContent: ReasoningContentType = {
      modality: "reasoning",
      value: {
        type: "redacted",
        data: "This reasoning has been redacted"
      },
      metadata: undefined
    };
    

    The value field can be one of two types:

    ReasoningContentValueType:

    FieldTypeDescriptionConstraints
    type"thinking"Indicates thinking contentMust be "thinking"
    thinkingstringThe thinking/reasoning textAny valid string
    signaturestringA signature for the reasoningAny valid string

    RedactedReasoningContentValueType:

    FieldTypeDescriptionConstraints
    type"redacted"Indicates redacted contentMust be "redacted"
    datastringThe redacted dataAny valid string

    Tool

    A ToolType represents a tool being sent to the LLM provider.

    FieldTypeDescriptionConstraints
    type"function"Indicates this is a function toolMust be "function"
    definitionObjectContains the schema of the functionMust contain a valid function schema
    definition.schemaFunctionTypeThe function schemaMust be a valid function schema

    For a valid function schema, refer to OpenAI Function Calling documentation.

    // Example of a tool
    const getWeatherTool: ToolType = {
      type: "function",
      definition: {
        schema: {
          name: "get_weather",
          description: "Get the current weather in a given location",
          parameters: {
            type: "object",
            properties: {
              location: {
                type: "string",
                description: "The city and state, e.g. San Francisco, CA"
              }
            },
            required: ["location"]
          }
        }
      }
    };
    
    // Example of a tool
    const searchDatabaseTool: ToolType = {
      type: "function",
      definition: {
        schema: {
          name: "search_database",
          description: "Search for records in the database",
          parameters: {
            type: "object",
            properties: {
              query: {
                type: "string",
                description: "The search query"
              },
              limit: {
                type: "number",
                description: "Maximum number of results to return",
                default: 10
              }
            },
            required: ["query"]
          }
        }
      }
    };