AI Skill Hub 推荐使用:AI路由器 是一款优质的AI工具。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。
AI路由器 是一款基于 TypeScript 开发的开源工具,专注于 ai-gateway、api-gateway、artificial-intelligence 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
AI路由器 是一款基于 TypeScript 开发的开源工具,专注于 ai-gateway、api-gateway、artificial-intelligence 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一: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
# 命令行使用
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"
┌────────────────────────────────────────────────────────────────────────────┐
│ 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 │
│ │
└────────────────────────────────────────────────────────────────────────────┘
---
---
$ 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)
---
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 }
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"])
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!"}] ) ```
```bash
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/chat/completions | OpenAI-compatible chat (streaming + non-streaming) |
| POST | /v1/completions | OpenAI text completions |
| POST | /v1/route | Routing decision without LLM call |
| GET | /v1/models | List available models with pricing |
| GET | /health | Provider health + cost summary |
| GET | /dashboard | Cost analytics dashboard |
Full API docs: docs/API.md
---
// 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';
---
| Scenario | Approach |
|---|---|
| Single query, route to cheapest capable model | Multi-signal scoring (default, <1ms) |
| Decompose task into sub-tasks, assign each to optimal agent | MCTS (finds optimal assignment) |
| Batch queries with different complexity levels | Heuristic scoring |
| Multi-turn workflow with branching decisions | MCTS |
| Rule-based | MCTS | |
|---|---|---|
| **Logic** | Hard-coded if/else | Learned from simulation |
| **Adaptivity** | Static | Adapts to agent performance |
| **Complexity** | O(n) | O(iterations × branching^depth) |
| **Exploration** | None | Balances explore/exploit |
| **Known strategies** | Fast | Slower but finds better strategies |
| **Scale** | Good for <10 agents | Scales 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.
---
| Feature | A3M 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) | No | No | |
| **Intelligent routing** | Multi-signal per-query | Manual selection | Manual | Manual | |
| **Zero ML / Zero GPU** | **Yes** | Yes | Yes | Yes | |
| **Package size** | 19.5 KB | ~50 MB | ~30 MB | API-only | |
| **OpenAI-compatible proxy** | **Yes** | No | Yes | Yes | Yes |
| **Adaptive memory** | **Yes** | No | No | No | No |
| **Semantic cache** | **Yes** (trigram) | No | No | Yes | No |
| **Prompt injection detection** | **Yes** (17 patterns) | No | No | Yes | No |
| **PII redaction** | **Yes** | No | No | Yes | No |
| **Hallucination checks** | **Yes** | No | No | No | No |
| **Cost analytics** | **Yes** | No | Yes | Yes | Yes |
| **Budget alerts** | **Yes** | No | No | Yes | No |
| **Circuit breaker** | **Yes** | No | No | Yes | No |
| **LangChain adapter** | **Yes** | No | Yes | Yes | No |
| **Python SDK** | **Yes** | Yes | Yes | Yes | Yes |
| **TypeScript SDK** | **Yes** | No | No | Yes | Yes |
| **CLI** | **Yes** | No | Yes | No | No |
| **Self-hosted** | **Yes** | Yes | Yes | Yes | No |
| **License** | MIT | Apache 2.0 | Custom | MIT | Proprietary |
Also consider: 9router, ClawRouter, Plano, Helicone
---
性能优秀,易于使用和扩展
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,AI路由器 是一款质量良好的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | 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 |
收录时间:2026-05-30 · 更新时间:2026-05-31 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。