能力标签
AI路由器
🛠
AI工具

AI路由器

基于 TypeScript · 开源免费,本地部署,数据完全自主可控
英文名:a3m-router
⭐ 7 Stars 💻 TypeScript 📄 MIT 🏷 AI 7.5分
7.5AI 综合评分
ai-gatewayapi-gatewayartificial-intelligencebenchmark
✦ AI Skill Hub 推荐

AI Skill Hub 推荐使用:AI路由器 是一款优质的AI工具。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。

📚 深度解析

AI路由器 是一款基于 TypeScript 的开源工具,在 GitHub 上收获 0k+ Star,是ai-gateway、api-gateway、artificial-intelligence、benchmark领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
AI路由器 依赖 TypeScript 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 TypeScript 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 AI路由器 的版本更新,及时通知重要功能变化。

📋 工具概览

AI路由器 是一款基于 TypeScript 开发的开源工具,专注于 ai-gateway、api-gateway、artificial-intelligence 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 7
开发语言
TypeScript
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
MIT
AI 综合评分
7.5 分
工具类型
AI工具
Forks

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

AI路由器 是一款基于 TypeScript 开发的开源工具,专注于 ai-gateway、api-gateway、artificial-intelligence 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:npm 全局安装
npm install -g a3m-router

# 方式二:npx 直接运行(无需安装)
npx a3m-router --help

# 方式三:项目依赖安装
npm install a3m-router

# 方式四:从源码运行
git clone https://github.com/Das-rebel/a3m-router
cd a3m-router
npm install
npm start
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
a3m-router --help

# 基本用法
a3m-router [options] <input>

# Node.js 代码中使用
const a3m_router = require('a3m-router');

const result = await a3m_router.run(options);
console.log(result);
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# a3m-router 配置说明
# 查看配置选项
a3m-router --config-example > config.yml

# 常见配置项
# output_dir: ./output
# log_level: info
# workers: 4

# 环境变量(覆盖配置文件)
export A3M_ROUTER_CONFIG="/path/to/config.yml"
📑 README 深度解析 真实文档 完整度 62/100 含工作流图 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

🇨🇳 中文 · 🇯🇵 日本語 · English

Features in Detail

Feature Overview

┌────────────────────────────────────────────────────────────────────────────┐
│                         A3M Router Features                               │
├────────────────────────────────────────────────────────────────────────────┤
│                                                                            │
│  ⚡ PARALLEL ENSEMBLE         │  🧠 ADAPTIVE MEMORY                         │
│  ────────────────────         │  ───────────────────                         │
│  • Run N providers at once    │  • MemoryTree storage                       │
│  • Confidence scoring         │  • EMA quality scoring                      │
│  • Transparent winner logic   │  • Learns from history                      │
│  • Historical feedback        │  • No retraining needed                     │
│                                                                            │
├────────────────────────────────────────────────────────────────────────────┤
│                                                                            │
│  🎯 INTELLIGENT ROUTING       │  💰 HARD BUDGET ENFORCEMENT                │
│  ─────────────────────         │  ───────────────────────                   │
│  ───────────────────────     │  ───────────────────                       │
│  • Per-user/team budgets     │  • 17-pattern injection detection           │
│  • Real-time spend tracking  │  • PII redaction                           │
│  • Alerts at 50/80/100%      │  • Content filtering                        │
│  • Hard caps (reject when exceeded)  │ • Hallucination checks              │
│                                                                            │
├────────────────────────────────────────────────────────────────────────────┤
│                                                                            │
│  🔄 INTELLIGENT FAILOVER     │  💾 SEMANTIC CACHE                         │
│  ───────────────────────     │  ───────────────────                        │
│  • Provider health scoring   │  • Embedding-based lookup                   │
│  • Circuit breaker (3 fails) │  • Configurable similarity threshold       │
│  • Automatic fallback chain  │  • Per-route TTL                           │
│  • Chinese provider handling │  • 30%+ cache hit rate                      │
│                                                                            │
├────────────────────────────────────────────────────────────────────────────┤
│                                                                            │
│  ⚡ PER-PROVIDER RETRY       │  📊 COST ANALYTICS                         │
│  ─────────────────────       │  ───────────────────                       │
│  • Custom timeout per model  │  • Per-provider breakdown                    │
│  • Exponential backoff       │  • Budget vs actual dashboard               │
│  • 429 rate limit handling   │  • Projected savings                        │
│  • Jitter to prevent storms  │  • Monthly/yearly reports                   │
│                                                                            │
└────────────────────────────────────────────────────────────────────────────┘

---

Enterprise Features

  • Hard Budget Enforcement — Per-user and per-team monthly budgets with hard caps. Real-time spend dashboard shows actual vs budget. Alerts fire at 50%, 80%, 100% thresholds. Per-provider cost breakdown shows exactly where every dollar goes.
  • Semantic Cache — Embedding-based cache lookup with configurable similarity threshold. Per-route TTL lets you set different cache durations for different routes. 30%+ cache hit rate means 30% fewer LLM API calls on repeated or similar queries.
  • Intelligent Failover — Provider health scoring combines latency and error rate into a live health score. Automatic fallback chain routes to the next healthy provider when the primary fails. Circuit breaker trips after 3 failures and cools for 60 seconds. Chinese providers receive specialized handling for their unique regional constraints.
  • Per-Provider Retry Logic — Custom timeout per provider. Exponential backoff with jitter. Rate limit detection (429) triggers intelligent backoff rather than blind retries that make the problem worse.

---

Quick Start

Terminal Demo

$ npx a3m-router serve
╔════════════════════════════════════════════════════════════╗
║                     A3M Router v2.9.2                      ║
║                🔀 Intelligent LLM Gateway                 ║
╠════════════════════════════════════════════════════════════╣
║  ✅ Proxy:     http://localhost:8787                      ║
║  ✅ Dashboard: http://localhost:8787/dashboard             ║
║  ✅ Health:    http://localhost:8787/health               ║
╚════════════════════════════════════════════════════════════╝

[GROQ]  ✅ 145ms  |  [DEEPSEEK]  ✅ 230ms  |  [KIMI]  ✅ 312ms
[ANTHROPIC]  ✅ 520ms  |  [OPENAI]  ✅ 480ms  |  [QWEN]  ✅ 290ms

🧠 Memory: 1,247 queries cached | 💰 Today: $2.34 / $50.00 budget
$ npx a3m-router route "Design a clinical trial for oncology"

🔀 Routing Decision:
   Query: "Design a clinical trial for oncology"
   
   📊 Complexity: 1.00 (premium)
   🏷️  Tier: premium
   
   ✅ Route to: openai/gpt-4o ($2.50/1M tokens)
   🔄 Fallback: anthropic/claude-3.5-sonnet
   
   💡 Signals: medical(+0.35) + design(+0.20) + multi-step(+0.15)
$ npx a3m-router cost

💰 Cost Analytics (May 2024)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Total Spend:     $127.45 / $500.00 budget
 Daily Average:   $4.27
 Queries:         28,392
 
📈 By Provider:          📊 By Tier:
 Groq:        $42.30  ████████ 33%   premium:   $89.10  70%
 DeepSeek:    $51.20  █████████ 40%   mid:       $28.90  23%
 Claude:      $28.90  █████     23%   cheap:     $7.45    6%
 GPT-4o-mini: $5.05   █         4%    free:      $2.00    1%

🚨 Budget Alert: Engineering team at 80% ($160 / $200)

---

TypeScript SDK

adaptive-memory-multi-model-router/sdk';

const router = new A3MRouter();

// Route a query — returns model + tier + cost + complexity
const decision = router.route("Review this contract for liability clauses");
// → { model: "anthropic/claude-3.5-sonnet", tier: "premium",
//     cost: 0.008, complexity: 0.87, isExpert: true }

// Analyze why it chose that model
const features = router.analyze("Review this contract for liability clauses");
// → { detectedDomain: "legal", domainScore: 0.35, hasCode: false,
//     requiresReasoning: true, complexity: 0.87 }

Python SDK

from a3m import A3MRouter

async with A3MRouter() as router:
    # Route without executing
    decision = await router.route("Write a Python function to sort an array")
    print(decision.model, decision.tier, decision.cost)
    # → groq/llama-3.3-70b cheap 0.0004

    # Execute via OpenAI-compatible chat
    response = await router.chat("What is 2+2?", model="auto")
    print(response["choices"][0]["message"]["content"])

Works with ANY OpenAI SDK — zero code changes

from openai import OpenAI client = OpenAI(base_url="http://localhost:8787/v1", api_key="not-needed")

response = client.chat.completions.create( model="auto", # ← intelligent routing kicks in messages=[{"role": "user", "content": "Hello!"}] ) ```

REST API

```bash

API Reference

MethodEndpointDescription
POST/v1/chat/completionsOpenAI-compatible chat (streaming + non-streaming)
POST/v1/completionsOpenAI text completions
POST/v1/routeRouting decision without LLM call
GET/v1/modelsList available models with pricing
GET/healthProvider health + cost summary
GET/dashboardCost analytics dashboard

Full API docs: docs/API.md

---

Package Exports

// Main — everything
adaptive-memory-multi-model-router';

// SDK — clean high-level API
adaptive-memory-multi-model-router/sdk';

// Individual modules
adaptive-memory-multi-model-router/cache';
adaptive-memory-multi-model-router/guardrails';
adaptive-memory-multi-model-router/cost';
adaptive-memory-multi-model-router/analytics';
adaptive-memory-multi-model-router/memory';
adaptive-memory-multi-model-router/langchain';
adaptive-memory-multi-model-router/providers';
adaptive-memory-multi-model-router/server';

// Ensemble (P0) — core differentiator
adaptive-memory-multi-model-router/ensemble';

// Query-type presets (P1)
adaptive-memory-multi-model-router/presets';

// Persistent memory (P3)
adaptive-memory-multi-model-router/memory';

---

When to Use MCTS vs Heuristic Scoring

ScenarioApproach
Single query, route to cheapest capable modelMulti-signal scoring (default, <1ms)
Decompose task into sub-tasks, assign each to optimal agentMCTS (finds optimal assignment)
Batch queries with different complexity levelsHeuristic scoring
Multi-turn workflow with branching decisionsMCTS

MCTS vs Rule-Based Assignment

Rule-basedMCTS
**Logic**Hard-coded if/elseLearned from simulation
**Adaptivity**StaticAdapts to agent performance
**Complexity**O(n)O(iterations × branching^depth)
**Exploration**NoneBalances explore/exploit
**Known strategies**FastSlower but finds better strategies
**Scale**Good for <10 agentsScales to 20+ agents
A3M Router (per-query routing)
└── Multi-signal scoring → fast (<1ms)
    └── Tier selection → cheapest available

TMLPD Orchestration (multi-agent workflows)
└── MCTS → optimal agent assignment
    ├── UCB1 selection
    ├── State tree expansion
    └── Reward backpropagation

Example workflow:

User: "Research AI safety, write a report, have experts review it, then publish"

MCTS decomposes into:
  research → deepseek (cost-effective for research)
  write → claude (best for structured long-form)
  review → expert-agents (human-in-loop or specialist LLM)
  publish → codex (can handle deployment code)

Router assigns each sub-task to optimal agent, tracks outcomes, learns preferences.

---

Comparison

FeatureA3M Router[LiteLLM](https://github.com/BerriAI/litellm)[Portkey](https://github.com/Portkey-AI/gateway)[OpenRouter](https://openrouter.ai)
**Parallel ensemble****✅**
**Confidence scoring****✅**
**Routing accuracy published****Yes** (76.43 ±1)No (manual)NoNo
**Intelligent routing**Multi-signal per-queryManual selectionManualManual
**Zero ML / Zero GPU****Yes**YesYesYes
**Package size**19.5 KB~50 MB~30 MBAPI-only
**OpenAI-compatible proxy****Yes**NoYesYesYes
**Adaptive memory****Yes**NoNoNoNo
**Semantic cache****Yes** (trigram)NoNoYesNo
**Prompt injection detection****Yes** (17 patterns)NoNoYesNo
**PII redaction****Yes**NoNoYesNo
**Hallucination checks****Yes**NoNoNoNo
**Cost analytics****Yes**NoYesYesYes
**Budget alerts****Yes**NoNoYesNo
**Circuit breaker****Yes**NoNoYesNo
**LangChain adapter****Yes**NoYesYesNo
**Python SDK****Yes**YesYesYesYes
**TypeScript SDK****Yes**NoNoYesYes
**CLI****Yes**NoYesNoNo
**Self-hosted****Yes**YesYesYesNo
**License**MITApache 2.0CustomMITProprietary

Also consider: 9router, ClawRouter, Plano, Helicone

---

🎯 aiskill88 AI 点评 A 级 2026-05-30

性能优秀,易于使用和扩展

📚 实用指南(长尾问题)
适合谁
  • 需要 a3m-router 解决具体问题的开发者与运营人员
最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
部署方案
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
a3m-router 中文教程a3m-router 安装报错怎么办a3m-router 与同类工具对比a3m-router 最佳实践a3m-router 适合谁用

⚡ 核心功能

👥 适合谁
  • 需要 a3m-router 解决具体问题的开发者与运营人员
⭐ 最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +MIT 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐

📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

a3m-router 是一款TypeScript开发的AI辅助工具。开源AI工具:🏆 #1 on LLM routing benchmark · Cheapest LLM router with memory · Open-source p。⭐7 · TypeScript 主要应用场景包括:AI模型路由和优化。
💡 AI Skill Hub 点评

总体来看,AI路由器 是一款质量良好的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

📚 深入学习 AI路由器
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 a3m-router
原始描述 开源AI工具:🏆 #1 on LLM routing benchmark · Cheapest LLM router with memory · Open-source p。⭐7 · TypeScript
Topics ai-gatewayapi-gatewayartificial-intelligencebenchmark
GitHub https://github.com/Das-rebel/a3m-router
License MIT
语言 TypeScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/Das-rebel/a3m-router 🌐 官方网站  https://das-rebel.github.io/a3m-router/

收录时间:2026-05-30 · 更新时间:2026-05-31 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。