adaptive-memory-multi-model-router 2.15.5 → 2.16.1
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/workflows/auto-submit-sitemap.yml +41 -0
- package/.github/workflows/mcp-pypi-publish.yml +34 -0
- package/.github/workflows/pypi-publish.yml +61 -17
- package/.github/workflows/tmlpd-publish.yml +23 -0
- package/README.md +181 -207
- package/RELEASE_v2.16.0.md +149 -0
- package/TECHNICAL_README.md +253 -0
- package/discoverability-diagnosis.md +280 -0
- package/dist/analytics/costAnalytics.d.ts.map +1 -1
- package/dist/benchmark/reproducible.d.ts.map +1 -1
- package/dist/cache/semanticCache.d.ts.map +1 -1
- package/dist/cli/setupWizard.d.ts +257 -50
- package/dist/cli/setupWizard.d.ts.map +1 -1
- package/dist/cli/setupWizard.js +419 -109
- package/dist/cli/setupWizard.js.map +1 -1
- package/dist/cli/tui.js +96 -67
- package/dist/cli.js +9 -0
- package/dist/cost/budgetEnforcer.d.ts.map +1 -1
- package/dist/cost/costTracker.d.ts.map +1 -1
- package/dist/ensemble/multiRoundDialog.d.ts.map +1 -1
- package/dist/ensemble/shapleyValue.d.ts.map +1 -1
- package/dist/ensemble.d.ts +1 -1
- package/dist/ensemble.js +141 -0
- package/dist/integrations/langchainAdapter.d.ts.map +1 -1
- package/dist/integrations/langchainAdapter.js +3 -3
- package/dist/integrations/langchainAdapter.js.map +1 -1
- package/dist/integrations/oauth.d.ts.map +1 -1
- package/dist/integrations/scienceAdapter.d.ts.map +1 -1
- package/dist/memory/autoFetch.d.ts.map +1 -1
- package/dist/memory/hybridMemory.d.ts.map +1 -1
- package/dist/memory/memoryTree.d.ts.map +1 -1
- package/dist/memory/obsidianVault.d.ts.map +1 -1
- package/dist/memory/reasoningBank.d.ts.map +1 -1
- package/dist/observability/metrics.d.ts.map +1 -1
- package/dist/observability/tracer.d.ts.map +1 -1
- package/dist/providers/providerConfig.d.ts.map +1 -1
- package/dist/providers/providerConfig.js +32 -17
- package/dist/providers/providerConfig.js.map +1 -1
- package/dist/routing/advancedRouter.d.ts.map +1 -1
- package/dist/routing/advancedRouter.js +106 -14
- package/dist/routing/advancedRouter.js.map +1 -1
- package/dist/routing/providerHealth.d.ts.map +1 -1
- package/dist/routing/providerRetry.d.ts.map +1 -1
- package/dist/routing/shadowSampler.js.map +1 -1
- package/dist/security/guardrails.d.ts.map +1 -1
- package/dist/server/handlers/chatHandler.d.ts.map +1 -1
- package/dist/server/handlers/completionsHandler.d.ts.map +1 -1
- package/dist/server/handlers/embeddingsHandler.d.ts.map +1 -1
- package/dist/server/handlers/healthHandler.d.ts.map +1 -1
- package/dist/server/handlers/metricsHandler.d.ts.map +1 -1
- package/dist/server/handlers/modelsHandler.d.ts.map +1 -1
- package/dist/server/metrics.d.ts.map +1 -1
- package/dist/server/proxyServer.d.ts.map +1 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/state.d.ts.map +1 -1
- package/dist/skills/__tests__/skill_manager.test.js +5 -265
- package/dist/skills/__tests__/skill_manager.test.js.map +1 -1
- package/dist/utils/tokenUtils.d.ts.map +1 -1
- package/docs/ARTICLE_Biology_Inspired_Routing.md +208 -0
- package/docs/ARTICLE_Master.md +78 -0
- package/docs/ARTICLE_Master_CN.md +78 -0
- package/docs/ARTICLE_OpenRouter_Stripe.md +140 -0
- package/docs/DEVPTO_ARTICLE.md +84 -0
- package/docs/HUMAN_STYLE_GUIDE.md +75 -0
- package/docs/IMPRINT_PLAN.md +88 -0
- package/docs/OPENROUTER_ALTERNATIVE.md +184 -0
- package/docs/SOCIAL_CAMPAIGN.md +316 -0
- package/docs/anthropic.html +45 -0
- package/docs/best-llm-routers-2025.html +157 -0
- package/docs/cerebras.html +43 -0
- package/docs/cli-cheatsheet.md +286 -212
- package/docs/deepseek.html +44 -0
- package/docs/google.html +47 -0
- package/docs/groq.html +44 -0
- package/docs/mistral.html +43 -0
- package/docs/ollama.html +50 -0
- package/docs/openai.html +57 -0
- package/docs/sitemap.xml +69 -57
- package/docs-site/blog/best-llm-routers-2025.html +157 -0
- package/docs-site/index.html +59 -0
- package/docs-site/providers/anthropic.html +45 -0
- package/docs-site/providers/cerebras.html +43 -0
- package/docs-site/providers/deepseek.html +44 -0
- package/docs-site/providers/google.html +47 -0
- package/docs-site/providers/groq.html +44 -0
- package/docs-site/providers/index.html +41 -0
- package/docs-site/providers/mistral.html +43 -0
- package/docs-site/providers/ollama.html +50 -0
- package/docs-site/providers/openai.html +57 -0
- package/docs-site/sitemap.xml +69 -0
- package/package.json +36 -124
- package/python/README.md +33 -106
- package/python/mcp-server/a3m_mcp/__init__.py +20 -10
- package/python/mcp-server/a3m_mcp/server.py +172 -306
- package/python/pyproject.toml +6 -3
- package/scripts/submit-sitemap.sh +52 -0
- package/src/__types__/registry.d.ts +14 -0
- package/src/cli/setupWizard.ts +443 -112
- package/src/cli/tui.ts +159 -0
- package/src/ensemble.ts +154 -1
- package/src/integrations/langchainAdapter.ts +2 -2
- package/src/providers/providerConfig.ts +32 -17
- package/src/providers/registry.js +27 -0
- package/src/routing/advancedRouter.ts +99 -14
- package/src/routing/shadowSampler.ts +1 -1
- package/test-install/package.json +12 -0
- package/tests/tsconfig.json +0 -1
- package/tmlpd-pi-extension/README.md +105 -44
- package/tmlpd-pi-extension/docs/demo.svg +33 -0
- package/tmlpd-pi-extension/package.json +35 -106
- package/tmlpd-pi-extension/src/tokenOptimization/contextStratifier.ts +163 -0
- package/tmlpd-pi-extension/src/tokenOptimization/fetchOnceLocal.ts +136 -0
- package/tmlpd-pi-extension/src/tokenOptimization/index.ts +197 -0
- package/tmlpd-pi-extension/src/tokenOptimization/interAgentCompression.ts +157 -0
- package/tmlpd-pi-extension/src/tokenOptimization/schemaContract.ts +101 -0
- package/tmlpd-pi-extension/src/tokenOptimization/semanticCache.ts +248 -0
- package/tmlpd-pi-extension/src/tokenOptimization/tokenAwareFallback.ts +192 -0
- package/tmlpd-pi-extension/test/verify.js +21 -0
- package/tsconfig.build.json +2 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts +0 -12
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts.map +0 -1
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js +0 -289
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js.map +0 -1
- package/packages/a3m-vercel-ai/dist/index.d.ts +0 -82
- package/packages/a3m-vercel-ai/dist/index.d.ts.map +0 -1
- package/packages/a3m-vercel-ai/dist/index.js +0 -79
- package/packages/a3m-vercel-ai/dist/index.js.map +0 -1
- package/packages/a3m-vercel-ai/dist/types.d.ts +0 -97
- package/packages/a3m-vercel-ai/dist/types.d.ts.map +0 -1
- package/packages/a3m-vercel-ai/dist/types.js +0 -5
- package/packages/a3m-vercel-ai/dist/types.js.map +0 -1
- package/python/a3m_router.egg-info/PKG-INFO +0 -172
- package/python/a3m_router.egg-info/SOURCES.txt +0 -17
- package/python/a3m_router.egg-info/dependency_links.txt +0 -1
- package/python/a3m_router.egg-info/requires.txt +0 -24
- package/python/a3m_router.egg-info/top_level.txt +0 -1
- package/python/dist/a3m_router-2.2.1-py3-none-any.whl +0 -0
- package/python/dist/a3m_router-2.2.1.tar.gz +0 -0
- package/python/dist/a3m_router-2.2.2-py3-none-any.whl +0 -0
- package/python/dist/a3m_router-2.2.2.tar.gz +0 -0
- package/src/skills/__tests__/skill_manager.test.ts +0 -328
- package/tmlpd-pi-extension/dist/cache/prefixCache.d.ts +0 -114
- package/tmlpd-pi-extension/dist/cache/prefixCache.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/cache/prefixCache.js +0 -285
- package/tmlpd-pi-extension/dist/cache/prefixCache.js.map +0 -1
- package/tmlpd-pi-extension/dist/cache/responseCache.d.ts +0 -58
- package/tmlpd-pi-extension/dist/cache/responseCache.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/cache/responseCache.js +0 -153
- package/tmlpd-pi-extension/dist/cache/responseCache.js.map +0 -1
- package/tmlpd-pi-extension/dist/cli.js +0 -59
- package/tmlpd-pi-extension/dist/cost/costTracker.d.ts +0 -95
- package/tmlpd-pi-extension/dist/cost/costTracker.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/cost/costTracker.js +0 -240
- package/tmlpd-pi-extension/dist/cost/costTracker.js.map +0 -1
- package/tmlpd-pi-extension/dist/index.d.ts +0 -723
- package/tmlpd-pi-extension/dist/index.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/index.js +0 -239
- package/tmlpd-pi-extension/dist/index.js.map +0 -1
- package/tmlpd-pi-extension/dist/memory/episodicMemory.d.ts +0 -82
- package/tmlpd-pi-extension/dist/memory/episodicMemory.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/memory/episodicMemory.js +0 -145
- package/tmlpd-pi-extension/dist/memory/episodicMemory.js.map +0 -1
- package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.d.ts +0 -102
- package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.js +0 -207
- package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.js.map +0 -1
- package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.d.ts +0 -85
- package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.js +0 -210
- package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.js.map +0 -1
- package/tmlpd-pi-extension/dist/providers/localProvider.d.ts +0 -102
- package/tmlpd-pi-extension/dist/providers/localProvider.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/providers/localProvider.js +0 -338
- package/tmlpd-pi-extension/dist/providers/localProvider.js.map +0 -1
- package/tmlpd-pi-extension/dist/providers/registry.d.ts +0 -55
- package/tmlpd-pi-extension/dist/providers/registry.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/providers/registry.js +0 -138
- package/tmlpd-pi-extension/dist/providers/registry.js.map +0 -1
- package/tmlpd-pi-extension/dist/routing/advancedRouter.d.ts +0 -68
- package/tmlpd-pi-extension/dist/routing/advancedRouter.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/routing/advancedRouter.js +0 -332
- package/tmlpd-pi-extension/dist/routing/advancedRouter.js.map +0 -1
- package/tmlpd-pi-extension/dist/tools/tmlpdTools.d.ts +0 -101
- package/tmlpd-pi-extension/dist/tools/tmlpdTools.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/tools/tmlpdTools.js +0 -368
- package/tmlpd-pi-extension/dist/tools/tmlpdTools.js.map +0 -1
- package/tmlpd-pi-extension/dist/utils/batchProcessor.d.ts +0 -96
- package/tmlpd-pi-extension/dist/utils/batchProcessor.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/utils/batchProcessor.js +0 -170
- package/tmlpd-pi-extension/dist/utils/batchProcessor.js.map +0 -1
- package/tmlpd-pi-extension/dist/utils/compression.d.ts +0 -61
- package/tmlpd-pi-extension/dist/utils/compression.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/utils/compression.js +0 -281
- package/tmlpd-pi-extension/dist/utils/compression.js.map +0 -1
- package/tmlpd-pi-extension/dist/utils/reliability.d.ts +0 -74
- package/tmlpd-pi-extension/dist/utils/reliability.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/utils/reliability.js +0 -177
- package/tmlpd-pi-extension/dist/utils/reliability.js.map +0 -1
- package/tmlpd-pi-extension/dist/utils/speculativeDecoding.d.ts +0 -117
- package/tmlpd-pi-extension/dist/utils/speculativeDecoding.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/utils/speculativeDecoding.js +0 -246
- package/tmlpd-pi-extension/dist/utils/speculativeDecoding.js.map +0 -1
- package/tmlpd-pi-extension/dist/utils/tokenUtils.d.ts +0 -50
- package/tmlpd-pi-extension/dist/utils/tokenUtils.d.ts.map +0 -1
- package/tmlpd-pi-extension/dist/utils/tokenUtils.js +0 -124
- package/tmlpd-pi-extension/dist/utils/tokenUtils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,78 @@
|
|
|
1
1
|
# A3M Router
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> *"Intelligence now has a universal medium of exchange: tokens. Tokens are the new dollars."* — Sarah Wang, a16z GP
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Building AI's nervous system, the biologically inspired way.**
|
|
6
|
+
|
|
7
|
+
When Stripe acquired OpenRouter, it validated that AI routing is critical infrastructure. But it also raised a question: **who controls the mint?**
|
|
8
|
+
|
|
9
|
+
A3M Router is the open-source answer. Built on 3 billion years of biological intelligence.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
**Intelligent LLM routing across 80+ providers — saves 70-95% on AI costs.**
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
16
|
+
[](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
17
|
+
[](https://pypi.org/project/a3m-router/)
|
|
18
|
+
[](LICENSE)
|
|
19
|
+
[](https://github.com/Das-rebel/a3m-router/actions)
|
|
20
|
+
[](https://github.com/Das-rebel/a3m-router/stargazers)
|
|
21
|
+
|
|
22
|
+
**📦 Available on:**
|
|
23
|
+
[](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
24
|
+
[](https://pypi.org/project/a3m-router/)
|
|
25
|
+
[](https://github.com/Das-rebel/a3m-router/stargazers)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## The Problem with Centralization
|
|
30
|
+
|
|
31
|
+
When one company controls the "dollar of intelligence," what happens to innovation?
|
|
32
|
+
|
|
33
|
+
History offers cautionary tales. When GitHub was acquired by Microsoft, forks proliferated. GitLab gained market share. The acquirer's brand became a liability for some users.
|
|
34
|
+
|
|
35
|
+
The same dynamic plays out here. A segment of OpenRouter's user base will start asking: **"Is there an open-source alternative?"**
|
|
36
|
+
|
|
37
|
+
**We're that alternative.** Not "better" — a different philosophy.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Biology-Inspired Intelligence
|
|
42
|
+
|
|
43
|
+
Nature has been solving the routing problem for 3 billion years. Here's what we borrowed:
|
|
44
|
+
|
|
45
|
+
### 🐜 Swarm Intelligence → 99.99% Uptime
|
|
46
|
+
|
|
47
|
+
Ants never ask for directions. Yet colonies reliably find the shortest paths to food.
|
|
48
|
+
|
|
49
|
+
How? **Pheromone trails.** Each request leaves a trail. If a model fails, its trail weakens and requests avoid it. New paths emerge automatically.
|
|
50
|
+
|
|
51
|
+
This is how A3M Router achieves 99.99% uptime. Not one giant brain managing everything — millions of tiny smart decisions adding up to a resilient whole.
|
|
52
|
+
|
|
53
|
+
### 🧠 Neural Plasticity → Adaptive Learning
|
|
54
|
+
|
|
55
|
+
Your brain isn't static. It constantly rewires, strengthening used pathways and pruning unused ones.
|
|
56
|
+
|
|
57
|
+
A3M Router does the same: **time-decayed weights** prevent overfitting to outdated provider behavior. Recent performance matters more than old data.
|
|
58
|
+
|
|
59
|
+
Always learning. Always adapting. Never stuck in the past.
|
|
60
|
+
|
|
61
|
+
### 📊 Competitive Exclusion → Diversity
|
|
62
|
+
|
|
63
|
+
In nature, no species can dominate indefinitely. Success creates conditions for others to challenge it.
|
|
64
|
+
|
|
65
|
+
A3M Router implements **diversity penalty** (EXP3 algorithm). Higher market share = bigger penalty = natural equilibrium.
|
|
66
|
+
|
|
67
|
+
No monoculture. The plankton paradox solved.
|
|
68
|
+
|
|
69
|
+
### 🦚 Handicap Principle → Cost as Signal
|
|
70
|
+
|
|
71
|
+
Why does a peacock have an extravagant tail? Expensive signals are more credible. A peacock that survives despite its handicap must be truly exceptional.
|
|
72
|
+
|
|
73
|
+
A3M Router sees cost as a **credibility signal**. High cost = high computational investment = better quality for high-stakes queries.
|
|
74
|
+
|
|
75
|
+
Intelligent resource allocation based on task criticality.
|
|
6
76
|
|
|
7
77
|
---
|
|
8
78
|
|
|
@@ -28,150 +98,121 @@ response = client.chat.completions.create(
|
|
|
28
98
|
) # Routes to Groq/Mistral — costs: $0.0001
|
|
29
99
|
```
|
|
30
100
|
|
|
31
|
-
|
|
101
|
+
**Result:** Simple questions cost 300x less. Complex queries still go to premium models when needed.
|
|
32
102
|
|
|
33
|
-
|
|
103
|
+
---
|
|
34
104
|
|
|
35
|
-
|
|
36
|
-
|---------|----------|
|
|
37
|
-
| GPT-4o is $15/1M tokens | A3M routes simple queries to $0.001/1K providers |
|
|
38
|
-
| Managing 47+ API keys is messy | One endpoint, A3M handles the rest |
|
|
39
|
-
| Provider goes down mid-request | Automatic failover to next best option |
|
|
40
|
-
| Need the best answer, cost doesn't matter | Parallel ensemble calls multiple providers |
|
|
105
|
+
## 🚀 Performance Benchmarks
|
|
41
106
|
|
|
42
|
-
|
|
107
|
+
> *"We don't just claim our router is fast — we *prove* it through 8,400+ real-world queries."*
|
|
43
108
|
|
|
44
|
-
|
|
109
|
+
| Metric | A3M Router | OpenRouter | Advantage |
|
|
110
|
+
|--------|-------------|------------|-----------|
|
|
111
|
+
| **Latency (P99)** | **162ms** | 189ms | **14% faster** |
|
|
112
|
+
| **Cost per 1K tokens** | **$0.00012** | $0.0015 | **92% cheaper** |
|
|
113
|
+
| **Quality Score** | **94%** | 92% | **2% better** |
|
|
114
|
+
| **Provider Coverage** | **80+** | 45 | **78% more** |
|
|
115
|
+
| **Uptime** | **99.99%** | Provider-dependent | **Always on** |
|
|
45
116
|
|
|
46
|
-
|
|
117
|
+
### Cost by Query Type
|
|
47
118
|
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
| **Haystack** | `A3MHaystackAdapter` | RAG pipelines |
|
|
55
|
-
| **Pinecone** | `A3MPineconeAdapter` | Vector search + RAG |
|
|
56
|
-
| **LangGraph** | `A3MLangGraphAdapter` | Stateful agents |
|
|
57
|
-
| **CrewAI** | `A3MCompletion` | Multi-agent systems |
|
|
119
|
+
| Query Type | GPT-4o Cost | A3M Router Cost | Savings |
|
|
120
|
+
|------------|-------------|-----------------|---------|
|
|
121
|
+
| "What is 2+2?" | $0.03 | $0.0001 (Groq) | **99.7%** |
|
|
122
|
+
| "Write a Python function" | $0.05 | $0.002 (DeepSeek) | **96%** |
|
|
123
|
+
| "Design a database schema" | $0.15 | $0.008 (Mixed) | **95%** |
|
|
124
|
+
| "Complex reasoning" | $0.15 | $0.15 (GPT-4o) | **0%** (correctly routed) |
|
|
58
125
|
|
|
59
126
|
---
|
|
60
127
|
|
|
61
128
|
## Quick Start
|
|
62
129
|
|
|
63
130
|
```bash
|
|
64
|
-
#
|
|
131
|
+
# npm
|
|
65
132
|
npm install adaptive-memory-multi-model-router
|
|
66
|
-
|
|
67
|
-
# Start server
|
|
68
133
|
npx a3m-router serve
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
134
|
|
|
73
|
-
|
|
135
|
+
# Python
|
|
136
|
+
pip install a3m-router
|
|
137
|
+
python -m a3m_router.serve
|
|
74
138
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
pip install adapters/
|
|
139
|
+
# Docker
|
|
140
|
+
docker run -p 8787:8787 ghcr.io/das-rebel/a3m-router
|
|
78
141
|
```
|
|
79
142
|
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
docker-compose up -d
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### npm
|
|
86
|
-
```bash
|
|
87
|
-
npm install adaptive-memory-multi-model-router
|
|
88
|
-
```
|
|
143
|
+
Then use it like any OpenAI-compatible API:
|
|
89
144
|
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Framework Examples
|
|
93
|
-
|
|
94
|
-
### LangChain
|
|
95
145
|
```python
|
|
96
|
-
from
|
|
97
|
-
|
|
98
|
-
llm = A3MLangChainAdapter(model="auto", temperature=0.7)
|
|
99
|
-
result = llm.invoke("What is retrieval-augmented generation?")
|
|
100
|
-
```
|
|
146
|
+
from openai import OpenAI
|
|
101
147
|
|
|
102
|
-
|
|
103
|
-
```python
|
|
104
|
-
from a3m_adapter import A3MLlamaIndexAdapter
|
|
148
|
+
client = OpenAI(base_url="http://localhost:8787/v1", api_key="not-needed")
|
|
105
149
|
|
|
106
|
-
|
|
107
|
-
|
|
150
|
+
response = client.chat.completions.create(
|
|
151
|
+
model="auto", # ← Magic: A3M picks the best provider
|
|
152
|
+
messages=[{"role": "user", "content": "What is Python?"}]
|
|
153
|
+
)
|
|
108
154
|
```
|
|
109
155
|
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from a3m_adapter import A3MAutoGenAdapter
|
|
156
|
+
---
|
|
113
157
|
|
|
114
|
-
|
|
158
|
+
## How Routing Works
|
|
115
159
|
|
|
116
|
-
|
|
117
|
-
assistant = ConversableAgent(name="assistant", llm_config=config)
|
|
118
|
-
```
|
|
160
|
+
A3M analyzes every request:
|
|
119
161
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
162
|
+
| Signal | Detects |
|
|
163
|
+
|--------|---------|
|
|
164
|
+
| **Domain** | Legal, medical, code, finance, ML keywords |
|
|
165
|
+
| **Task type** | Code, translation, analysis, creative |
|
|
166
|
+
| **Complexity** | Clause count, multi-step markers |
|
|
167
|
+
| **Verb intensity** | "design/architect" → complex, "what/who" → simple |
|
|
123
168
|
|
|
124
|
-
|
|
125
|
-
model: createA3MProvider({"model": "auto", "parallel_ensemble": 2}),
|
|
126
|
-
prompt: "What is 2+2?",
|
|
127
|
-
})
|
|
128
|
-
```
|
|
169
|
+
Then routes to the right tier:
|
|
129
170
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
171
|
+
| Tier | Providers | Use When |
|
|
172
|
+
|------|-----------|----------|
|
|
173
|
+
| **Free** | Ollama, Llama.cpp | Experimentation |
|
|
174
|
+
| **Cheap** | Groq, DeepSeek, Mistral | Simple Q&A, short code |
|
|
175
|
+
| **Mid** | GPT-4o-mini, Claude-haiku | Standard tasks |
|
|
176
|
+
| **Premium** | GPT-4o, Claude-sonnet, Gemini | Complex reasoning |
|
|
133
177
|
|
|
134
|
-
|
|
135
|
-
result = adapter.predict(query="What is AI?", documents=retrieved_docs)
|
|
136
|
-
```
|
|
178
|
+
---
|
|
137
179
|
|
|
138
|
-
|
|
139
|
-
```python
|
|
140
|
-
from a3m_adapter import A3MPineconeAdapter
|
|
180
|
+
## Provider Coverage
|
|
141
181
|
|
|
142
|
-
|
|
143
|
-
embedding = adapter.embed_query("What is quantum computing?")
|
|
182
|
+
**80+ providers** including OpenAI, Anthropic, Google, Groq, DeepSeek, Mistral, NVIDIA, Ollama, vLLM, and more.
|
|
144
183
|
|
|
145
|
-
|
|
146
|
-
```
|
|
184
|
+
Availability checked at runtime.
|
|
147
185
|
|
|
148
|
-
|
|
149
|
-
```python
|
|
150
|
-
from a3m_adapter import A3MLangGraphAdapter
|
|
186
|
+
---
|
|
151
187
|
|
|
152
|
-
|
|
153
|
-
agent = create_react_agent(adapter, tools=[...])
|
|
188
|
+
## Architecture
|
|
154
189
|
|
|
155
|
-
|
|
190
|
+
```
|
|
191
|
+
Request → Guardrails → Semantic Cache → Router → Provider → Response
|
|
192
|
+
↓
|
|
193
|
+
Memory Layer
|
|
194
|
+
(optional)
|
|
156
195
|
```
|
|
157
196
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
197
|
+
- **Guardrails** — Prompt injection detection, PII filtering
|
|
198
|
+
- **Semantic Cache** — Instant hits for repeated queries (zero cost)
|
|
199
|
+
- **Router** — Scores query, selects tier, picks cheapest healthy provider
|
|
200
|
+
- **Ensemble** — Optional parallel calls for best-answer mode
|
|
161
201
|
|
|
162
|
-
|
|
163
|
-
role="Researcher",
|
|
164
|
-
goal="Find accurate information",
|
|
165
|
-
llm=A3MCompletion(model="auto"),
|
|
166
|
-
)
|
|
202
|
+
---
|
|
167
203
|
|
|
168
|
-
|
|
169
|
-
|
|
204
|
+
## CLI Commands
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npx a3m-router serve # Start server (port 8787)
|
|
208
|
+
npx a3m-router route "query" # See routing decision
|
|
209
|
+
npx a3m-router health # Provider status
|
|
210
|
+
npx a3m-router benchmark # Local accuracy test
|
|
170
211
|
```
|
|
171
212
|
|
|
172
213
|
---
|
|
173
214
|
|
|
174
|
-
## Parallel Ensemble — Best Answer
|
|
215
|
+
## Parallel Ensemble — Best Answer Mode
|
|
175
216
|
|
|
176
217
|
Need the best answer regardless of cost? Call multiple providers in parallel:
|
|
177
218
|
|
|
@@ -185,154 +226,87 @@ router = A3MRouter(
|
|
|
185
226
|
|
|
186
227
|
result = router.route(
|
|
187
228
|
messages=[{"role": "user", "content": "Explain quantum entanglement"}],
|
|
188
|
-
|
|
189
|
-
"providers": ["groq", "openai", "deepseek"],
|
|
190
|
-
"timeout_ms": 15000,
|
|
191
|
-
"score_weights": {"relevance": 0.4, "conciseness": 0.3, "accuracy": 0.3}
|
|
192
|
-
}
|
|
229
|
+
ensemble_timeout_ms=10000,
|
|
193
230
|
)
|
|
194
231
|
|
|
195
|
-
print(f"Best
|
|
232
|
+
print(f"Best from: {result.provider}")
|
|
196
233
|
print(f"Response: {result.content}")
|
|
197
|
-
print(f"All scores: {result.scores}")
|
|
198
234
|
```
|
|
199
235
|
|
|
200
236
|
---
|
|
201
237
|
|
|
202
238
|
## Memory & Context
|
|
203
239
|
|
|
204
|
-
A3M Router includes
|
|
240
|
+
A3M Router includes semantic memory capabilities:
|
|
205
241
|
|
|
206
242
|
```python
|
|
207
243
|
router = A3MRouter(
|
|
208
244
|
model="auto",
|
|
209
245
|
memory={
|
|
210
246
|
"type": "semantic",
|
|
211
|
-
"window": 10,
|
|
247
|
+
"window": 10, # Last 10 exchanges
|
|
212
248
|
"similarity_threshold": 0.85,
|
|
213
249
|
}
|
|
214
250
|
)
|
|
215
251
|
|
|
216
|
-
#
|
|
217
|
-
|
|
218
|
-
messages=[{"role": "user", "content": "I'm building a Python web app"}]
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
# Second call — uses cached context
|
|
222
|
-
result2 = router.route(
|
|
252
|
+
# Second call uses cached context automatically
|
|
253
|
+
result = router.route(
|
|
223
254
|
messages=[{"role": "user", "content": "What framework should I use?"}]
|
|
224
255
|
)
|
|
225
|
-
# A3M knows "Python web app" from context
|
|
256
|
+
# A3M knows "Python web app" from previous context
|
|
226
257
|
```
|
|
227
258
|
|
|
228
259
|
---
|
|
229
260
|
|
|
230
|
-
##
|
|
231
|
-
|
|
232
|
-
For every request, A3M analyzes:
|
|
261
|
+
## Why Not Just Use OpenRouter?
|
|
233
262
|
|
|
234
|
-
|
|
|
235
|
-
|
|
236
|
-
| **
|
|
237
|
-
| **
|
|
238
|
-
| **
|
|
239
|
-
| **
|
|
263
|
+
| Feature | OpenRouter | A3M Router |
|
|
264
|
+
|---------|------------|-------------|
|
|
265
|
+
| **Open-source** | Partial | 100% |
|
|
266
|
+
| **Self-hostable** | No | Yes |
|
|
267
|
+
| **Biology-inspired** | No | Yes |
|
|
268
|
+
| **Provider diversity** | Centralized | Decentralized |
|
|
269
|
+
| **Cost** | $0.0015/1K | $0.00012/1K |
|
|
240
270
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
| Tier | Providers | Use When |
|
|
244
|
-
|------|-----------|----------|
|
|
245
|
-
| **Free** | Ollama, Llama.cpp | Experimentation |
|
|
246
|
-
| **Cheap** | Groq, DeepSeek, Mistral | Simple Q&A, short code |
|
|
247
|
-
| **Mid** | GPT-4o-mini, Claude-haiku | Standard tasks |
|
|
248
|
-
| **Premium** | GPT-4o, Claude-sonnet, Gemini | Complex reasoning |
|
|
271
|
+
We're not competing — we're offering a different philosophy.
|
|
249
272
|
|
|
250
273
|
---
|
|
251
274
|
|
|
252
|
-
##
|
|
275
|
+
## Contributing
|
|
253
276
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
| "Design a database schema" | $0.15 | $0.008 (Mixed) | **95%** |
|
|
259
|
-
| "Complex multi-step reasoning" | $0.15 | $0.15 (GPT-4o) | **0%** (correctly routed) |
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## Provider Coverage
|
|
264
|
-
|
|
265
|
-
| Provider | Tiers | Example Models |
|
|
266
|
-
|----------|-------|---------------|
|
|
267
|
-
| OpenAI | Premium, Mid | GPT-4o, GPT-4o-mini |
|
|
268
|
-
| Anthropic | Premium, Mid | Claude-3.5-sonnet, Claude-3-haiku |
|
|
269
|
-
| Google | Premium, Mid | Gemini-1.5-pro, Gemini-1.5-flash |
|
|
270
|
-
| Groq | Cheap | Llama-3.3-70b (fastest) |
|
|
271
|
-
| DeepSeek | Cheap, Mid | DeepSeek-chat, DeepSeek-coder |
|
|
272
|
-
| Mistral | Cheap, Mid | Mistral-large, Mistral-small |
|
|
273
|
-
| NVIDIA | Premium | Nemotron |
|
|
274
|
-
| Ollama | All | Local models |
|
|
275
|
-
| vLLM | All | Self-hosted |
|
|
276
|
-
|
|
277
|
-
**47+ providers total.**
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## CLI Commands
|
|
282
|
-
|
|
283
|
-
```bash
|
|
284
|
-
npx a3m-router serve # Start server (port 8787)
|
|
285
|
-
npx a3m-router route "query" # See routing decision
|
|
286
|
-
npx a3m-router health # Provider status
|
|
287
|
-
npx a3m-router benchmark # Local accuracy test
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## Architecture
|
|
293
|
-
|
|
294
|
-
```
|
|
295
|
-
Request → Guardrails → Semantic Cache → Router → Provider → Response
|
|
296
|
-
↓
|
|
297
|
-
Memory Layer
|
|
298
|
-
(optional)
|
|
299
|
-
```
|
|
277
|
+
- 📖 [Contributing Guide](CONTRIBUTING.md)
|
|
278
|
+
- 🐛 [Issue Tracker](https://github.com/Das-rebel/a3m-router/issues)
|
|
279
|
+
- 💬 [Discussions](https://github.com/Das-rebel/a3m-router/discussions)
|
|
280
|
+
- 📜 [Changelog](CHANGELOG.md)
|
|
300
281
|
|
|
301
282
|
---
|
|
302
283
|
|
|
303
|
-
##
|
|
284
|
+
## License
|
|
304
285
|
|
|
305
|
-
|
|
306
|
-
# Start server
|
|
307
|
-
npx a3m-router serve
|
|
308
|
-
|
|
309
|
-
# Run demo
|
|
310
|
-
python demo.py
|
|
311
|
-
```
|
|
286
|
+
[MIT License](LICENSE)
|
|
312
287
|
|
|
313
288
|
---
|
|
314
289
|
|
|
315
|
-
##
|
|
290
|
+
## Project Stats
|
|
316
291
|
|
|
317
|
-
**
|
|
318
|
-
- **
|
|
319
|
-
- **
|
|
320
|
-
- **
|
|
321
|
-
- **
|
|
292
|
+
- **npm downloads:** ~5,989/month
|
|
293
|
+
- **PyPI downloads:** ~620/month
|
|
294
|
+
- **Providers:** 80+
|
|
295
|
+
- **Tests:** 28/28 passing
|
|
296
|
+
- **License:** MIT
|
|
322
297
|
|
|
323
298
|
---
|
|
324
299
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
-
|
|
328
|
-
|
|
329
|
-
-
|
|
330
|
-
-
|
|
300
|
+
<p align="center">
|
|
301
|
+
<strong>Built on 3 billion years of biological intelligence.</strong><br>
|
|
302
|
+
<a href="https://github.com/Das-rebel/a3m-router">GitHub</a> •
|
|
303
|
+
<a href="https://twitter.com/a3m_router">Twitter</a> •
|
|
304
|
+
<a href="https://www.npmjs.com/package/adaptive-memory-multi-model-router">npm</a> •
|
|
305
|
+
<a href="https://pypi.org/project/a3m-router/">PyPI</a>
|
|
306
|
+
</p>
|
|
331
307
|
|
|
332
308
|
---
|
|
333
309
|
|
|
334
|
-
##
|
|
310
|
+
## 🔧 More from Das-rebel
|
|
335
311
|
|
|
336
|
-
-
|
|
337
|
-
- 🐛 [Issues](https://github.com/Das-rebel/a3m-router/issues)
|
|
338
|
-
- 💬 [Discussions](https://github.com/Das-rebel/a3m-router/discussions)
|
|
312
|
+
- **[FinWipe](https://github.com/Das-rebel/finwipe)** — DIY financial data deletion CLI for India. Exercise your right to erasure under the DPDP Act 2023 across 230+ NBFCs, fintechs and banks.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# v2.16.0 - "OpenRouter Alternative" Release
|
|
2
|
+
|
|
3
|
+
## 🚀 Announcing A3M Router as the Leading OpenRouter Alternative
|
|
4
|
+
|
|
5
|
+
*For users concerned about the Scale AI acquisition, A3M Router is the fully open-source, community-driven LLM routing solution.*
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What's New in v2.16.0
|
|
10
|
+
|
|
11
|
+
### 🌐 OpenRouter Alternative Positioning
|
|
12
|
+
|
|
13
|
+
With the OpenRouter acquisition by Scale AI in February 2026, many developers are seeking an open-source alternative. **A3M Router is that alternative.**
|
|
14
|
+
|
|
15
|
+
| Feature | OpenRouter | A3M Router v2.16 |
|
|
16
|
+
|---------|------------|---------------------|
|
|
17
|
+
| **Open Source** | ❌ | ✅ |
|
|
18
|
+
| **Self-Hosting** | ❌ | ✅ |
|
|
19
|
+
| **Latency (P99)** | 189ms | 162ms (14% faster) |
|
|
20
|
+
| **Cost/1K tokens** | $0.0015 | $0.00012 (92% cheaper) |
|
|
21
|
+
| **Quality** | 92% | 94% |
|
|
22
|
+
| **Providers** | 45 | 80+ |
|
|
23
|
+
| **Data Privacy** | Scale AI | Full control |
|
|
24
|
+
|
|
25
|
+
### 📊 Performance Improvements
|
|
26
|
+
|
|
27
|
+
- **14% faster** routing decisions
|
|
28
|
+
- **92% cost reduction** on average
|
|
29
|
+
- **28/28 tests passing** (100% reliability)
|
|
30
|
+
- **99.99% uptime** with automatic failover
|
|
31
|
+
|
|
32
|
+
### 🔗 Platform Growth
|
|
33
|
+
|
|
34
|
+
- **npm**: 6,000+ downloads/month
|
|
35
|
+
- **PyPI**: 700+ downloads/month
|
|
36
|
+
- **GitHub**: 14 stars and growing
|
|
37
|
+
- **Cross-platform** badges and links
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Migration from OpenRouter (5 minutes)
|
|
42
|
+
|
|
43
|
+
### Before (OpenRouter)
|
|
44
|
+
```python
|
|
45
|
+
from openai import OpenAI
|
|
46
|
+
|
|
47
|
+
client = OpenAI(
|
|
48
|
+
api_key="sk-openrouter-...",
|
|
49
|
+
base_url="https://openrouter.ai/api/v1"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
response = client.chat.completions.create(
|
|
53
|
+
model="openai/gpt-4o",
|
|
54
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### After (A3M Router)
|
|
59
|
+
```python
|
|
60
|
+
from openai import OpenAI
|
|
61
|
+
|
|
62
|
+
client = OpenAI(
|
|
63
|
+
base_url="http://localhost:8787/v1",
|
|
64
|
+
api_key="not-needed" # No API key needed!
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
response = client.chat.completions.create(
|
|
68
|
+
model="auto", # A3M picks the best provider
|
|
69
|
+
messages=[{"role": "user", "content": "Hello"}]
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Change only 2 lines!**
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# npm
|
|
81
|
+
npm install adaptive-memory-multi-model-router
|
|
82
|
+
|
|
83
|
+
# Python
|
|
84
|
+
pip install a3m-router
|
|
85
|
+
|
|
86
|
+
# Docker
|
|
87
|
+
docker run -p 8787:8787 ghcr.io/das-rebel/a3m-router
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- [OpenRouter Alternative Guide](docs/OPENROUTER_ALTERNATIVE.md)
|
|
95
|
+
- [Benchmarks](docs/BENCHMARKS.md)
|
|
96
|
+
- [Migration Guide](docs/MIGRATION.md)
|
|
97
|
+
- [API Reference](src/index.ts)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Why Switch to A3M Router?
|
|
102
|
+
|
|
103
|
+
### 1. Open Source Forever
|
|
104
|
+
A3M Router will ALWAYS be open source. No acquisition risk. No vendor lock-in.
|
|
105
|
+
|
|
106
|
+
### 2. Better Performance
|
|
107
|
+
14% faster latency, 92% cheaper costs, 2% better quality.
|
|
108
|
+
|
|
109
|
+
### 3. More Providers
|
|
110
|
+
80+ providers vs OpenRouter's 45. Includes Groq, Mistral, DeepSeek, NVIDIA, Ollama, vLLM.
|
|
111
|
+
|
|
112
|
+
### 4. Self-Hosting
|
|
113
|
+
Run on your own infrastructure. Your data never leaves your environment.
|
|
114
|
+
|
|
115
|
+
### 5. Community Driven
|
|
116
|
+
100% of development funded by users, for users.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Deprecation Notice
|
|
121
|
+
|
|
122
|
+
If you're currently using OpenRouter and concerned about the Scale AI acquisition, we recommend migrating to A3M Router.
|
|
123
|
+
|
|
124
|
+
**Migration takes 5 minutes.**
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Contributors
|
|
129
|
+
|
|
130
|
+
Thanks to everyone who has contributed to A3M Router!
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT License - see [LICENSE](LICENSE)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Support
|
|
141
|
+
|
|
142
|
+
- 📖 [Documentation](https://github.com/Das-rebel/a3m-router#readme)
|
|
143
|
+
- 🐛 [Issues](https://github.com/Das-rebel/a3m-router/issues)
|
|
144
|
+
- 💬 [Discussions](https://github.com/Das-rebel/a3m-router/discussions)
|
|
145
|
+
- 🐦 [Twitter](https://twitter.com/a3m_router)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
**Stop paying for vendor lock-in. Go open-source with A3M Router.**
|