adaptive-memory-multi-model-router 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +2 -0
- package/.well-known/ai-plugin.json +16 -0
- package/CONTRIBUTING.md +21 -93
- package/README.md +716 -140
- package/SECURITY.md +14 -54
- package/articles/FRESH_devto.md +460 -0
- package/articles/FRESH_hackernews.md +14 -0
- package/articles/FRESH_reddit_ml.md +90 -0
- package/articles/FRESH_reddit_node.md +198 -0
- package/articles/FRESH_reddit_sideproject.md +72 -0
- package/articles/FRESH_reddit_webdev.md +130 -0
- package/docs/GEO.md +53 -111
- package/docs/HN_CHECKLIST.md +38 -0
- package/docs/HN_FOUNDER_COMMENT.md +17 -0
- package/docs/HN_SUBMISSION_V3.md +56 -0
- package/docs/index.html +63 -88
- package/docs/openapi.json +139 -0
- package/docs/robots.txt +37 -0
- package/docs/sitemap.xml +21 -0
- package/llms-full.txt +155 -0
- package/llms.txt +37 -71
- package/package.json +74 -56
package/llms.txt
CHANGED
|
@@ -1,85 +1,51 @@
|
|
|
1
1
|
# A3M Router
|
|
2
|
-
> LLM
|
|
2
|
+
> Intelligent LLM routing with adaptive memory — 99.5% ±1 tier accuracy, zero ML, zero GPU. OpenAI-compatible proxy across 36 providers with semantic cache, guardrails, and cost analytics.
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
- Only router besides RouteLLM with **published benchmarks**
|
|
9
|
-
- 200-query MMLU-based benchmark with 4-tier routing (free/cheap/mid/premium)
|
|
4
|
+
## Three Core Capabilities
|
|
5
|
+
1. **Adaptive Memory** — Learns from usage patterns. Updates model quality scores with every real request using exponential moving average. No retraining needed.
|
|
6
|
+
2. **Multi-Signal Routing** — 5-signal complexity scoring: domain detection (legal, medical, finance, security, architecture, ML), task indicators (code, math, creative, multilingual), query structure, action verb intensity, multi-step detection. All regex + keyword, zero ML.
|
|
7
|
+
3. **Production Protections** — Semantic cache (trigram Jaccard similarity), 17-pattern prompt injection detection, PII redaction, content filtering, hallucination checks, cost analytics with budget alerts, circuit breaker with auto-failover.
|
|
10
8
|
|
|
11
|
-
##
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
## What
|
|
17
|
-
A3M Router is an OpenAI-compatible proxy that analyzes each query and routes it to the cheapest capable LLM provider. Keyword-based routing achieves near-ML accuracy at a fraction of the cost. Zero config. Zero GPU.
|
|
9
|
+
## Benchmark
|
|
10
|
+
- 64.5% exact tier match, 99.5% ±1 tier accuracy (200 queries, 4 tiers)
|
|
11
|
+
- 61.6% cost savings vs premium-only routing
|
|
12
|
+
- RouteLLM-inspired methodology, self-benchmarked
|
|
18
13
|
|
|
19
14
|
## Install
|
|
20
15
|
```bash
|
|
21
|
-
npm install adaptive-memory-multi-model-router
|
|
22
|
-
|
|
16
|
+
npm install adaptive-memory-multi-model-router # TypeScript/Node
|
|
17
|
+
pip install a3m-router # Python
|
|
18
|
+
npx a3m-router serve # Proxy at localhost:8787
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
## Interfaces
|
|
22
|
+
- **TypeScript SDK:** `import { A3MRouter } from 'adaptive-memory-multi-model-router/sdk'`
|
|
23
|
+
- **Python SDK:** `from a3m import A3MRouter` (async) or `from a3m import A3MRouterSync`
|
|
24
|
+
- **CLI:** `npx a3m-router route/serve/benchmark/health/cost/compare`
|
|
25
|
+
- **Proxy:** OpenAI-compatible at `localhost:8787/v1`
|
|
26
|
+
- **REST API:** POST /v1/route, POST /v1/chat/completions, GET /v1/models, GET /health
|
|
27
|
+
- **LangChain:** `import { A3MChatModel } from 'adaptive-memory-multi-model-router/langchain'`
|
|
28
|
+
|
|
29
|
+
## 36 Providers by Tier
|
|
30
|
+
- **Free (6):** CommandCode, Ollama, LM Studio, vLLM, OpenCode, Google (free tier)
|
|
31
|
+
- **Cheap (15):** Groq, Cerebras, DeepInfra, Together, Fireworks, Novita, SambaNova, Anyscale, Replicate, OpenRouter, Zhipu (GLM), Moonshot (Kimi), Yi, Baichuan, MiniMax
|
|
32
|
+
- **Mid (9):** DeepSeek, Mistral, Perplexity, Cohere, AI21, Qwen, StepFun, AlephAlpha, Deepset
|
|
33
|
+
- **Premium (3):** OpenAI, Anthropic, xAI (Grok)
|
|
34
|
+
- **Enterprise (3):** Azure OpenAI, AWS Bedrock, Google Vertex
|
|
34
35
|
|
|
35
36
|
## Features
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- Semantic cache
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
## Providers by Cost
|
|
47
|
-
- FREE: CommandCode, Ollama, LM Studio, vLLM
|
|
48
|
-
- $0.59-0.60/1M tokens: Groq, Cerebras
|
|
49
|
-
- $1.50-2.80/1M tokens: DeepSeek, MiniMax, Mistral, Qwen, GLM-4
|
|
50
|
-
- $10-30/1M tokens: Google, Anthropic, OpenAI
|
|
51
|
-
|
|
52
|
-
## API
|
|
53
|
-
```javascript
|
|
54
|
-
const { createA3MRouter } = require('adaptive-memory-multi-model-router');
|
|
55
|
-
const router = createA3MRouter();
|
|
56
|
-
const result = await router.route("Your query");
|
|
57
|
-
console.log(result.primary_model); // "groq/llama-3.3-70b"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## CLI
|
|
61
|
-
```bash
|
|
62
|
-
npx a3m-router serve # Start OpenAI-compatible proxy on :8787
|
|
63
|
-
npx a3m-router route "query" # Route a single query
|
|
64
|
-
npx a3m-router benchmark # Benchmark all providers
|
|
65
|
-
npx a3m-router providers # List configured providers
|
|
66
|
-
npx a3m-router status # Show router status
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Use Cases
|
|
70
|
-
- Reduce OpenAI API costs by 50-80%
|
|
71
|
-
- LLM routing without GPU
|
|
72
|
-
- Drop-in OpenAI proxy with cost optimization
|
|
73
|
-
- Route between local (Ollama) and cloud models
|
|
74
|
-
- Build multi-provider AI applications
|
|
75
|
-
- Add guardrails and caching to existing LLM setups
|
|
76
|
-
|
|
77
|
-
## Competitive Positioning
|
|
78
|
-
- vs RouteLLM: Matches accuracy within 2.5%, no GPU needed, includes proxy+cache+guardrails
|
|
79
|
-
- vs LiteLLM: Published benchmarks, zero-config, built-in semantic cache
|
|
80
|
-
- vs OpenRouter: Self-hosted, no middleman fees, open source
|
|
37
|
+
- Multi-signal routing with 5 weighted signals (domain, task, structure, verbs, specificity)
|
|
38
|
+
- Online learning via exponential moving average on model quality scores
|
|
39
|
+
- Semantic cache using character trigram Jaccard similarity (no vector DB, no embeddings)
|
|
40
|
+
- Guardrails: 17-pattern injection detection, PII detection/redaction (email, phone, SSN, CC, API keys, IP), content filtering, hallucination heuristics
|
|
41
|
+
- Cost analytics: per-provider spend tracking, budget alerts (daily/monthly/per-model), savings vs GPT-4o baseline
|
|
42
|
+
- Circuit breaker: 3 failures → 60s cooldown, automatic provider failover
|
|
43
|
+
- OpenAI-compatible proxy auto-detects provider format (OpenAI, Anthropic, Google, Ollama)
|
|
44
|
+
- LangChain adapter (A3MChatModel drop-in for ChatOpenAI)
|
|
45
|
+
- Streaming support (SSE relay)
|
|
46
|
+
- Obsidian vault integration for decision logging
|
|
81
47
|
|
|
82
48
|
## Links
|
|
83
49
|
- GitHub: https://github.com/Das-rebel/adaptive-memory-multi-model-router
|
|
84
|
-
-
|
|
50
|
+
- npm: https://www.npmjs.org/package/adaptive-memory-multi-model-router
|
|
85
51
|
- License: MIT
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
|
-
"description": "LLM router & AI gateway
|
|
6
|
+
"description": "LLM router & AI gateway — 99.5% routing accuracy, 47 Chinese LLM providers (DeepSeek, Kimi, Zhipu, Qwen, Yi, Baichuan, MiniMax). Multi-signal routing, semantic cache, guardrails, cost analytics. TypeScript SDK + Python SDK + CLI + OpenAI proxy.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
9
9
|
"a3m-router": "dist/cli.js",
|
|
@@ -53,71 +53,89 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
56
|
+
"llm-proxy",
|
|
57
|
+
"claude",
|
|
56
58
|
"ai",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"benchmark",
|
|
59
|
+
"openai-compatible",
|
|
60
|
+
"no-gpu",
|
|
61
|
+
"openai",
|
|
62
|
+
"routing-accuracy",
|
|
63
|
+
"minimax",
|
|
64
|
+
"portkey-alternative",
|
|
65
|
+
"中文llm",
|
|
66
|
+
"provider-fallback",
|
|
67
|
+
"nlp",
|
|
68
|
+
"ollama",
|
|
68
69
|
"cerebras",
|
|
70
|
+
"openai-sdk",
|
|
71
|
+
"ai-sdk",
|
|
72
|
+
"openai-proxy",
|
|
69
73
|
"cerebras-proxy",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
74
|
+
"深度求索",
|
|
75
|
+
"anthropic",
|
|
76
|
+
"ai-cost-optimization",
|
|
77
|
+
"model-router",
|
|
78
|
+
"model-routing",
|
|
79
|
+
"chinese-ai",
|
|
80
|
+
"vercel-ai",
|
|
81
|
+
"ai-load-balancer",
|
|
75
82
|
"deepseek",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"helicone",
|
|
83
|
+
"llm-routing",
|
|
84
|
+
"mistral",
|
|
85
|
+
"ollama-proxy",
|
|
86
|
+
"moonshot",
|
|
87
|
+
"stepfun",
|
|
88
|
+
"cost-optimization",
|
|
83
89
|
"keyword-routing",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
90
|
+
"zhipu",
|
|
91
|
+
"llm-manager",
|
|
92
|
+
"ai-router",
|
|
93
|
+
"multi-provider",
|
|
94
|
+
"yi-llm",
|
|
95
|
+
"chinese-llm",
|
|
96
|
+
"glms",
|
|
88
97
|
"llm",
|
|
89
|
-
"llm-gateway",
|
|
90
98
|
"llm-load-balancer",
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
99
|
+
"language-model",
|
|
100
|
+
"claude-proxy",
|
|
101
|
+
"lightweight",
|
|
102
|
+
"chatgpt",
|
|
103
|
+
"smart-routing",
|
|
104
|
+
"阿里qwen",
|
|
105
|
+
"zh-llm",
|
|
106
|
+
"中文ai",
|
|
107
|
+
"benchmark",
|
|
108
|
+
"helicone",
|
|
97
109
|
"mistral-proxy",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
110
|
+
"llm-orchestration",
|
|
111
|
+
"openrouter",
|
|
112
|
+
"kimi",
|
|
113
|
+
"moonshot-kimi",
|
|
114
|
+
"guardrails",
|
|
115
|
+
"ai-agent",
|
|
116
|
+
"baichuan",
|
|
117
|
+
"routellm-alternative",
|
|
118
|
+
"anthropic-proxy",
|
|
119
|
+
"token-counter",
|
|
120
|
+
"deepseek-proxy",
|
|
121
|
+
"llm-gateway",
|
|
100
122
|
"multi-llm",
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
123
|
+
"ai-gateway",
|
|
124
|
+
"groq",
|
|
125
|
+
"litellm-alternative",
|
|
126
|
+
"ai-proxy",
|
|
127
|
+
"llm-router",
|
|
128
|
+
"domain-routing",
|
|
129
|
+
"groq-proxy",
|
|
130
|
+
"qwen",
|
|
131
|
+
"gpt",
|
|
107
132
|
"openai-api",
|
|
108
|
-
"openai-compatible",
|
|
109
|
-
"openai-proxy",
|
|
110
|
-
"openai-sdk",
|
|
111
|
-
"openrouter",
|
|
112
|
-
"portkey-alternative",
|
|
113
|
-
"provider-fallback",
|
|
114
133
|
"query-routing",
|
|
115
|
-
"
|
|
116
|
-
"routing-accuracy",
|
|
134
|
+
"aleph-alpha",
|
|
117
135
|
"semantic-cache",
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
136
|
+
"langchain",
|
|
137
|
+
"ai-guardrails",
|
|
138
|
+
"chatbot"
|
|
121
139
|
],
|
|
122
140
|
"author": "Das-rebel <subho@example.com>",
|
|
123
141
|
"license": "MIT",
|
|
@@ -153,4 +171,4 @@
|
|
|
153
171
|
"@types/node": "^25.8.0",
|
|
154
172
|
"typescript": "^6.0.3"
|
|
155
173
|
}
|
|
156
|
-
}
|
|
174
|
+
}
|