adaptive-memory-multi-model-router 2.15.3 β 2.15.5
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/adapters-ci.yml +142 -0
- package/.github/workflows/ci.yml +2 -5
- package/.github/workflows/pypi-publish.yml +102 -0
- package/CHANGELOG.md +7 -1
- package/README.md +260 -137
- package/README_ja.md +2 -2
- package/README_zh.md +1 -1
- package/adapters/README.md +36 -0
- package/adapters/__init__.py +25 -0
- package/adapters/a3m_adapter/__init__.py +51 -0
- package/adapters/a3m_adapter/adapter/__init__.py +22 -0
- package/adapters/a3m_adapter/adapter/autogen.py +169 -0
- package/adapters/a3m_adapter/adapter/config.py +100 -0
- package/adapters/a3m_adapter/adapter/haystack.py +197 -0
- package/adapters/a3m_adapter/adapter/langchain.py +155 -0
- package/adapters/a3m_adapter/adapter/langgraph.py +196 -0
- package/adapters/a3m_adapter/adapter/llamaindex.py +162 -0
- package/adapters/a3m_adapter/adapter/pinecone.py +217 -0
- package/adapters/a3m_adapter/adapter/vercel.py +188 -0
- package/adapters/a3m_adapter/tests/__init__.py +1 -0
- package/adapters/a3m_adapter/tests/test_adapters.py +118 -0
- package/adapters/a3m_adapter/tests/test_integration.py +80 -0
- package/adapters/requirements-dev.txt +6 -0
- package/adapters/requirements.txt +4 -0
- package/adapters/setup.py +23 -0
- package/apps/cost-calculator/README.md +72 -0
- package/apps/cost-calculator/calculator.css +280 -0
- package/apps/cost-calculator/calculator.js +150 -0
- package/apps/cost-calculator/index.html +321 -0
- package/apps/cost-calculator/package.json +13 -0
- package/articles/ANNOUNCEMENT_reddit_ml.md +76 -0
- package/articles/ANNOUNCEMENT_vc/347/244/276/345/214/272.md +71 -0
- package/articles/ANNOUNCEMENT_vercel.md +85 -0
- package/demo.py +251 -0
- package/dist/providers/providerConfig.d.ts +5 -1
- package/dist/providers/providerConfig.js +1006 -1
- package/dist/providers/providerConfig.js.map +1 -1
- package/docker-compose.yml +84 -60
- package/docs/comparison.md +2 -2
- package/docs/llms-full.txt +360 -138
- package/docs/llms.txt +70 -71
- package/docs-site/index.html +9 -9
- package/llms.txt +70 -62
- package/package.json +41 -91
- package/packages/a3m-vercel-ai/README.md +161 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts +12 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js +289 -0
- package/packages/a3m-vercel-ai/dist/a3m-language-model.js.map +1 -0
- package/packages/a3m-vercel-ai/dist/index.d.ts +82 -0
- package/packages/a3m-vercel-ai/dist/index.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/index.js +79 -0
- package/packages/a3m-vercel-ai/dist/index.js.map +1 -0
- package/packages/a3m-vercel-ai/dist/types.d.ts +97 -0
- package/packages/a3m-vercel-ai/dist/types.d.ts.map +1 -0
- package/packages/a3m-vercel-ai/dist/types.js +5 -0
- package/packages/a3m-vercel-ai/dist/types.js.map +1 -0
- package/packages/a3m-vercel-ai/package-lock.json +969 -0
- package/packages/a3m-vercel-ai/package.json +46 -0
- package/packages/a3m-vercel-ai/src/a3m-language-model.ts +381 -0
- package/packages/a3m-vercel-ai/src/index.ts +104 -0
- package/packages/a3m-vercel-ai/src/types.ts +116 -0
- package/packages/a3m-vercel-ai/tsconfig.json +20 -0
- package/packages/agentkit-adapter/LICENSE +21 -0
- package/packages/agentkit-adapter/README.md +126 -0
- package/packages/agentkit-adapter/examples/agentkit-example.ts +139 -0
- package/packages/agentkit-adapter/package.json +57 -0
- package/packages/agentkit-adapter/src/adapter.ts +381 -0
- package/packages/agentkit-adapter/src/index.ts +36 -0
- package/packages/agentkit-adapter/src/types.ts +105 -0
- package/packages/agentkit-adapter/src/util.ts +13 -0
- package/packages/agentkit-adapter/tsconfig.json +22 -0
- package/prometheus.yml +8 -0
- package/python/README.md +92 -65
- package/python/a3m/__init__.py +32 -3
- package/python/a3m/adapters/__init__.py +21 -0
- package/python/a3m/adapters/langchain.py +190 -0
- package/python/a3m/adapters/llamaindex.py +249 -0
- package/python/a3m/adapters/qdrant.py +240 -0
- package/python/a3m/adapters/weaviate.py +263 -0
- package/python/a3m/client.py +5 -0
- package/python/a3m_router.egg-info/PKG-INFO +172 -0
- package/python/a3m_router.egg-info/SOURCES.txt +17 -0
- package/python/a3m_router.egg-info/dependency_links.txt +1 -0
- package/python/a3m_router.egg-info/requires.txt +24 -0
- package/python/a3m_router.egg-info/top_level.txt +1 -0
- package/python/build_verify.sh +32 -0
- 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/python/mcp-server/README.md +172 -0
- package/python/mcp-server/a3m_mcp/__init__.py +15 -0
- package/python/mcp-server/a3m_mcp/__main__.py +15 -0
- package/python/mcp-server/a3m_mcp/server.py +339 -0
- package/python/mcp-server/pyproject.toml +24 -0
- package/python/pyproject.toml +56 -5
- package/python/setup.py +3 -28
- package/src/providers/providerConfig.ts +1053 -1
- package/summary.txt +38 -0
- package/tsconfig.build.json +1 -2
package/docs/llms.txt
CHANGED
|
@@ -1,77 +1,76 @@
|
|
|
1
|
-
# A3M Router
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
# A3M Router β LLM Indexable Documentation
|
|
2
|
+
|
|
3
|
+
## What is A3M Router?
|
|
4
|
+
|
|
5
|
+
A3M Router is an intelligent LLM routing proxy that automatically selects the cheapest capable model for each request across 47+ providers. Saves 70-95% on AI costs.
|
|
6
|
+
|
|
7
|
+
## Framework Adapters (8 Total)
|
|
8
|
+
|
|
9
|
+
| Adapter | Framework | Use Case |
|
|
10
|
+
|---------|-----------|---------|
|
|
11
|
+
| A3MLangChainAdapter | LangChain | Chain-based AI workflows |
|
|
12
|
+
| A3MLlamaIndexAdapter | LlamaIndex | RAG and document qa |
|
|
13
|
+
| A3MAutoGenAdapter | AutoGen | Multi-agent conversations |
|
|
14
|
+
| A3MVercelAdapter | Vercel AI SDK | Next.js apps |
|
|
15
|
+
| A3MHaystackAdapter | Haystack | RAG pipelines |
|
|
16
|
+
| A3MPineconeAdapter | Pinecone | Vector search + RAG |
|
|
17
|
+
| A3MLangGraphAdapter | LangGraph | Stateful agents |
|
|
18
|
+
| A3MCompletion | CrewAI | Multi-agent systems |
|
|
19
|
+
|
|
20
|
+
## Core Capabilities
|
|
21
|
+
|
|
22
|
+
### 1. Automatic Model Selection
|
|
23
|
+
- Analyzes query complexity (domain, task type, structure, verb intensity)
|
|
24
|
+
- Maps to tier: Free β Cheap β Mid β Premium
|
|
25
|
+
- Selects cheapest healthy provider within tier
|
|
26
|
+
- Routing happens in ~140ms overhead
|
|
27
|
+
|
|
28
|
+
### 2. Parallel Ensemble Execution
|
|
29
|
+
- Call multiple providers simultaneously
|
|
30
|
+
- Score responses on quality metrics
|
|
31
|
+
- Return best answer with full provenance
|
|
32
|
+
- Use case: "best answer regardless of cost" mode
|
|
33
|
+
|
|
34
|
+
### 3. Biology-Inspired Routing
|
|
35
|
+
- EXP3: Prevents provider monoculture
|
|
36
|
+
- Charnov MVT: Optimal rate-limit rotation timing
|
|
37
|
+
- ODT Shadow Verification: Probabilistic verification for high-stakes queries
|
|
38
|
+
|
|
39
|
+
### 4. Semantic Memory
|
|
40
|
+
- Embedding-based conversation context
|
|
41
|
+
- Cross-session fact retention
|
|
42
|
+
- Adaptive forgetting of stale info
|
|
43
|
+
- Semantic cache for zero-cost repeated queries
|
|
44
|
+
|
|
45
|
+
## Supported Providers (47+)
|
|
46
|
+
|
|
47
|
+
OpenAI, Anthropic, Google, Groq, DeepSeek, Mistral, NVIDIA, Ollama, vLLM, Azure OpenAI, AWS Bedrock, and 37 more.
|
|
48
|
+
|
|
49
|
+
## API Endpoints
|
|
50
|
+
|
|
51
|
+
- POST /v1/chat/completions β OpenAI-compatible chat
|
|
52
|
+
- POST /v1/completions β Text completions
|
|
53
|
+
- POST /v1/embeddings β Embeddings
|
|
54
|
+
- GET /v1/models β Available models
|
|
55
|
+
- GET /health β Provider health
|
|
56
|
+
- GET /metrics β Prometheus metrics
|
|
57
|
+
|
|
58
|
+
## Cost Savings
|
|
59
|
+
|
|
60
|
+
| Query | GPT-4o | A3M | Savings |
|
|
61
|
+
|-------|---------|-----|---------|
|
|
62
|
+
| Simple Q&A | $0.03 | $0.0001 | 99.7% |
|
|
63
|
+
| Code generation | $0.05 | $0.002 | 96% |
|
|
64
|
+
| Complex reasoning | $0.15 | $0.15 | 0% (correct) |
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
57
67
|
|
|
58
68
|
```bash
|
|
59
69
|
npm install adaptive-memory-multi-model-router
|
|
60
|
-
|
|
70
|
+
pip install adapters/
|
|
71
|
+
docker-compose up -d
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
##
|
|
64
|
-
```
|
|
65
|
-
@software{a3m_router,
|
|
66
|
-
title = {A3M Router: OpenAI-Compatible Parallel LLM Routing Gateway},
|
|
67
|
-
author = {Subho Mukherjee},
|
|
68
|
-
year = {2025},
|
|
69
|
-
url = {https://github.com/Das-rebel/a3m-router}
|
|
70
|
-
}
|
|
71
|
-
```
|
|
74
|
+
## Keywords
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
- RouteWorks/RouterArena (ICLR 2025): https://github.com/RouteWorks/RouterArena
|
|
75
|
-
- MilkThink-Lab/RouterEval (EMNLP 2025): https://github.com/MilkThink-Lab/RouterEval
|
|
76
|
-
- Hunter-Wrynn/MMR-Bench (ArXiv 2026): https://github.com/Hunter-Wrynn/MMR-Bench
|
|
77
|
-
- ynulihao/LLMRouterBench (ACL 2026): https://github.com/ynulihao/LLMRouterBench
|
|
76
|
+
llm-router, ai-gateway, model-routing, cost-optimization, multi-provider, openai-compatible, langchain, llamaindex, autogena, vercel-ai, haystack, pinecone, langgraph, crewai, parallel-execution, semantic-cache, adaptive-routing, failover, guardrails, cache, budget-alerts, streaming, retries, circuit-breaker, multi-agent, rag, embeddings, vector-search
|
package/docs-site/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<!-- Primary SEO Meta Tags -->
|
|
8
8
|
<title>A3M Router β Parallel LLM Routing Gateway</title>
|
|
9
|
-
<meta name="description" content="
|
|
9
|
+
<meta name="description" content="Intelligent LLM routing proxy. Routes queries to cheapest capable model across 47+ providers. 96.77% RouterArena accuracy, $0.0768 per 1K tokens. Drop-in OpenAI-compatible API.">
|
|
10
10
|
<meta name="keywords" content="llm router benchmark, llm routing accuracy, routellm alternative, litellm alternative, llm cost optimization, openai proxy free, llm gateway open source, lightweight llm router, keyword-based llm routing, drop-in openai proxy, llm routing without gpu, how to reduce openai api costs">
|
|
11
11
|
<meta name="author" content="A3M Router Team">
|
|
12
12
|
<meta name="robots" content="index, follow, max-snippet:-1, max-image-preview:large">
|
|
@@ -468,20 +468,20 @@
|
|
|
468
468
|
|
|
469
469
|
<div class="stats">
|
|
470
470
|
<div class="stat">
|
|
471
|
-
<div class="stat-value">
|
|
472
|
-
<div class="stat-label">Downloads
|
|
471
|
+
<div class="stat-value">5,400+</div>
|
|
472
|
+
<div class="stat-label">Monthly Downloads</div>
|
|
473
473
|
</div>
|
|
474
474
|
<div class="stat">
|
|
475
|
-
<div class="stat-value">
|
|
476
|
-
<div class="stat-label">
|
|
475
|
+
<div class="stat-value">47+</div>
|
|
476
|
+
<div class="stat-label">LLM Providers</div>
|
|
477
477
|
</div>
|
|
478
478
|
<div class="stat">
|
|
479
|
-
<div class="stat-value">
|
|
480
|
-
<div class="stat-label">
|
|
479
|
+
<div class="stat-value">96.77%</div>
|
|
480
|
+
<div class="stat-label">RouterArena Accuracy</div>
|
|
481
481
|
</div>
|
|
482
482
|
<div class="stat">
|
|
483
|
-
<div class="stat-value"
|
|
484
|
-
<div class="stat-label">
|
|
483
|
+
<div class="stat-value">$0.08</div>
|
|
484
|
+
<div class="stat-label">Per 1K Tokens</div>
|
|
485
485
|
</div>
|
|
486
486
|
</div>
|
|
487
487
|
|
package/llms.txt
CHANGED
|
@@ -1,68 +1,76 @@
|
|
|
1
|
-
# A3M Router
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
OpenAI
|
|
1
|
+
# A3M Router β LLM Indexable Documentation
|
|
2
|
+
|
|
3
|
+
## What is A3M Router?
|
|
4
|
+
|
|
5
|
+
A3M Router is an intelligent LLM routing proxy that automatically selects the cheapest capable model for each request across 47+ providers. Saves 70-95% on AI costs.
|
|
6
|
+
|
|
7
|
+
## Framework Adapters (8 Total)
|
|
8
|
+
|
|
9
|
+
| Adapter | Framework | Use Case |
|
|
10
|
+
|---------|-----------|---------|
|
|
11
|
+
| A3MLangChainAdapter | LangChain | Chain-based AI workflows |
|
|
12
|
+
| A3MLlamaIndexAdapter | LlamaIndex | RAG and document qa |
|
|
13
|
+
| A3MAutoGenAdapter | AutoGen | Multi-agent conversations |
|
|
14
|
+
| A3MVercelAdapter | Vercel AI SDK | Next.js apps |
|
|
15
|
+
| A3MHaystackAdapter | Haystack | RAG pipelines |
|
|
16
|
+
| A3MPineconeAdapter | Pinecone | Vector search + RAG |
|
|
17
|
+
| A3MLangGraphAdapter | LangGraph | Stateful agents |
|
|
18
|
+
| A3MCompletion | CrewAI | Multi-agent systems |
|
|
19
|
+
|
|
20
|
+
## Core Capabilities
|
|
21
|
+
|
|
22
|
+
### 1. Automatic Model Selection
|
|
23
|
+
- Analyzes query complexity (domain, task type, structure, verb intensity)
|
|
24
|
+
- Maps to tier: Free β Cheap β Mid β Premium
|
|
25
|
+
- Selects cheapest healthy provider within tier
|
|
26
|
+
- Routing happens in ~140ms overhead
|
|
27
|
+
|
|
28
|
+
### 2. Parallel Ensemble Execution
|
|
29
|
+
- Call multiple providers simultaneously
|
|
30
|
+
- Score responses on quality metrics
|
|
31
|
+
- Return best answer with full provenance
|
|
32
|
+
- Use case: "best answer regardless of cost" mode
|
|
33
|
+
|
|
34
|
+
### 3. Biology-Inspired Routing
|
|
35
|
+
- EXP3: Prevents provider monoculture
|
|
36
|
+
- Charnov MVT: Optimal rate-limit rotation timing
|
|
37
|
+
- ODT Shadow Verification: Probabilistic verification for high-stakes queries
|
|
38
|
+
|
|
39
|
+
### 4. Semantic Memory
|
|
40
|
+
- Embedding-based conversation context
|
|
41
|
+
- Cross-session fact retention
|
|
42
|
+
- Adaptive forgetting of stale info
|
|
43
|
+
- Semantic cache for zero-cost repeated queries
|
|
44
|
+
|
|
45
|
+
## Supported Providers (47+)
|
|
46
|
+
|
|
47
|
+
OpenAI, Anthropic, Google, Groq, DeepSeek, Mistral, NVIDIA, Ollama, vLLM, Azure OpenAI, AWS Bedrock, and 37 more.
|
|
48
|
+
|
|
49
|
+
## API Endpoints
|
|
50
|
+
|
|
51
|
+
- POST /v1/chat/completions β OpenAI-compatible chat
|
|
52
|
+
- POST /v1/completions β Text completions
|
|
53
|
+
- POST /v1/embeddings β Embeddings
|
|
54
|
+
- GET /v1/models β Available models
|
|
55
|
+
- GET /health β Provider health
|
|
56
|
+
- GET /metrics β Prometheus metrics
|
|
57
|
+
|
|
58
|
+
## Cost Savings
|
|
59
|
+
|
|
60
|
+
| Query | GPT-4o | A3M | Savings |
|
|
61
|
+
|-------|---------|-----|---------|
|
|
62
|
+
| Simple Q&A | $0.03 | $0.0001 | 99.7% |
|
|
63
|
+
| Code generation | $0.05 | $0.002 | 96% |
|
|
64
|
+
| Complex reasoning | $0.15 | $0.15 | 0% (correct) |
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
48
67
|
|
|
49
68
|
```bash
|
|
50
69
|
npm install adaptive-memory-multi-model-router
|
|
51
|
-
|
|
70
|
+
pip install adapters/
|
|
71
|
+
docker-compose up -d
|
|
52
72
|
```
|
|
53
73
|
|
|
54
|
-
##
|
|
55
|
-
```
|
|
56
|
-
@software{a3m_router,
|
|
57
|
-
title = {A3M Router: OpenAI-Compatible Parallel LLM Routing Gateway},
|
|
58
|
-
author = {Subho Mukherjee},
|
|
59
|
-
year = {2025},
|
|
60
|
-
url = {https://github.com/Das-rebel/a3m-router}
|
|
61
|
-
}
|
|
62
|
-
```
|
|
74
|
+
## Keywords
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
- RouteWorks/RouterArena (ICLR 2025): https://github.com/RouteWorks/RouterArena
|
|
66
|
-
- MilkThink-Lab/RouterEval (EMNLP 2025): https://github.com/MilkThink-Lab/RouterEval
|
|
67
|
-
- Hunter-Wrynn/MMR-Bench (ArXiv 2026): https://github.com/Hunter-Wrynn/MMR-Bench
|
|
68
|
-
- ynulihao/LLMRouterBench (ACL 2026): https://github.com/ynulihao/LLMRouterBench
|
|
76
|
+
llm-router, ai-gateway, model-routing, cost-optimization, multi-provider, openai-compatible, langchain, llamaindex, autogena, vercel-ai, haystack, pinecone, langgraph, crewai, parallel-execution, semantic-cache, adaptive-routing, failover, guardrails, cache, budget-alerts, streaming, retries, circuit-breaker, multi-agent, rag, embeddings, vector-search
|
package/package.json
CHANGED
|
@@ -1,58 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.15.
|
|
4
|
-
"shortName": "A3M Router",
|
|
5
|
-
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
3
|
+
"version": "2.15.5",
|
|
6
4
|
"description": "Best in class open source LLM router across 47+ providers with Evolution-inspired routing: EXP3 diversity, MVT rate-limit rotation, optimal defense theory verification.",
|
|
7
|
-
"main": "
|
|
5
|
+
"main": "src/index.js",
|
|
8
6
|
"bin": {
|
|
9
|
-
"a3m-router": "dist/cli.js",
|
|
10
|
-
"a3m": "dist/
|
|
11
|
-
"a3m-tui": "dist/tui/index.js",
|
|
12
|
-
"adaptive-memory-multi-model-router": "dist/cli.js"
|
|
7
|
+
"a3m-router": "./dist/cli.js",
|
|
8
|
+
"a3m": "./dist/cli.js"
|
|
13
9
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"./cache": {
|
|
19
|
-
"import": "./dist/cache/semanticCache.js",
|
|
20
|
-
"require": "./dist/cache/semanticCache.js",
|
|
21
|
-
"types": "./dist/cache/semanticCache.d.ts"
|
|
22
|
-
},
|
|
23
|
-
"./compression": "./dist/utils/enhancedCompression.js",
|
|
24
|
-
"./autofetch": "./dist/memory/autoFetch.js",
|
|
25
|
-
"./vault": "./dist/memory/obsidianVault.js",
|
|
26
|
-
"./oauth": "./dist/integrations/oauth.js",
|
|
27
|
-
"./utils": "./dist/utils/tokenUtils.js",
|
|
28
|
-
"./cost": "./dist/cost/costTracker.js",
|
|
29
|
-
"./integrations": "./dist/integrations/index.js",
|
|
30
|
-
"./security": "./dist/security/inputValidation.js",
|
|
31
|
-
"./langchain": {
|
|
32
|
-
"import": "./dist/integrations/langchainAdapter.js",
|
|
33
|
-
"require": "./dist/integrations/langchainAdapter.js",
|
|
34
|
-
"types": "./dist/integrations/langchainAdapter.d.ts"
|
|
35
|
-
},
|
|
36
|
-
"./geo": "./dist/geo/generativeEngineOptimization.js",
|
|
37
|
-
"./server": {
|
|
38
|
-
"import": "./dist/server/proxyServer.js",
|
|
39
|
-
"require": "./dist/server/proxyServer.js",
|
|
40
|
-
"types": "./dist/server/proxyServer.d.ts"
|
|
41
|
-
},
|
|
42
|
-
"./guardrails": {
|
|
43
|
-
"import": "./dist/security/guardrails.js",
|
|
44
|
-
"require": "./dist/security/guardrails.js",
|
|
45
|
-
"types": "./dist/security/guardrails.d.ts"
|
|
46
|
-
},
|
|
47
|
-
"./analytics": {
|
|
48
|
-
"import": "./dist/analytics/costAnalytics.js",
|
|
49
|
-
"require": "./dist/analytics/costAnalytics.js",
|
|
50
|
-
"types": "./dist/analytics/costAnalytics.d.ts"
|
|
51
|
-
},
|
|
52
|
-
"./sdk": {
|
|
53
|
-
"import": "./dist/sdk.js",
|
|
54
|
-
"require": "./dist/sdk.js"
|
|
55
|
-
}
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node dist/cli.js serve",
|
|
12
|
+
"test": "node --test",
|
|
13
|
+
"lint": "eslint src/"
|
|
56
14
|
},
|
|
57
15
|
"keywords": [
|
|
58
16
|
"a3m",
|
|
@@ -154,55 +112,47 @@
|
|
|
154
112
|
"llm-failover",
|
|
155
113
|
"api-cost-reduction",
|
|
156
114
|
"multi-llm-router",
|
|
157
|
-
"multi-model-router"
|
|
115
|
+
"multi-model-router",
|
|
116
|
+
"llm-proxy",
|
|
117
|
+
"api-gateway",
|
|
118
|
+
"reverse-proxy",
|
|
119
|
+
"kubernetes",
|
|
120
|
+
"docker",
|
|
121
|
+
"browser-automation",
|
|
122
|
+
"playwright",
|
|
123
|
+
"puppeteer",
|
|
124
|
+
"web-scraping",
|
|
125
|
+
"anti-detection",
|
|
126
|
+
"stealth-browser",
|
|
127
|
+
"crawling",
|
|
128
|
+
"text-extraction",
|
|
129
|
+
"data-extraction",
|
|
130
|
+
"form-filling",
|
|
131
|
+
"content-generation",
|
|
132
|
+
"model-selection",
|
|
133
|
+
"provider-aggregation",
|
|
134
|
+
"langchain-adapter",
|
|
135
|
+
"llamaindex-adapter",
|
|
136
|
+
"vector-search",
|
|
137
|
+
"embeddings",
|
|
138
|
+
"nvidia-nim",
|
|
139
|
+
"ollama",
|
|
140
|
+
"vllm"
|
|
158
141
|
],
|
|
159
|
-
"author": "Das-rebel <subho@example.com>",
|
|
160
|
-
"license": "MIT",
|
|
161
142
|
"repository": {
|
|
162
143
|
"type": "git",
|
|
163
|
-
"url": "
|
|
164
|
-
},
|
|
165
|
-
"bugs": {
|
|
166
|
-
"url": "https://github.com/Das-rebel/a3m-router/issues"
|
|
144
|
+
"url": "https://github.com/Das-rebel/a3m-router"
|
|
167
145
|
},
|
|
168
146
|
"homepage": "https://das-rebel.github.io/a3m-router/",
|
|
169
|
-
"scripts": {
|
|
170
|
-
"test": "node test.js && node test/provider-test.js",
|
|
171
|
-
"test:py": "python3 -m pytest -q",
|
|
172
|
-
"test:all": "npm test && npm run test:py",
|
|
173
|
-
"eval:routing": "node eval/run_eval.js",
|
|
174
|
-
"eval:golden": "node eval/check_golden_routes.js",
|
|
175
|
-
"eval:faults": "node eval/run_fault_injection.js",
|
|
176
|
-
"eval:shadow": "node eval/run_shadow_eval.js",
|
|
177
|
-
"eval:report": "node eval/generate_report.js",
|
|
178
|
-
"eval:all": "npm run eval:routing && npm run eval:golden && npm run eval:faults && npm run eval:shadow && npm run eval:report",
|
|
179
|
-
"test:providers": "node test/provider-test.js",
|
|
180
|
-
"benchmark": "node test/benchmark.js",
|
|
181
|
-
"benchmark:verbose": "node test/benchmark.js --verbose",
|
|
182
|
-
"build": "npx tsc -p tsconfig.build.json",
|
|
183
|
-
"postinstall": "node scripts/postinstall-nudge.js"
|
|
184
|
-
},
|
|
185
|
-
"engines": {
|
|
186
|
-
"node": ">=18.0.0"
|
|
187
|
-
},
|
|
188
|
-
"peerDependencies": {
|
|
189
|
-
"@langchain/core": ">=0.1.0"
|
|
190
|
-
},
|
|
191
|
-
"peerDependenciesMeta": {
|
|
192
|
-
"@langchain/core": {
|
|
193
|
-
"optional": true
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
147
|
"dependencies": {
|
|
197
148
|
"blessed": "^0.1.81",
|
|
198
149
|
"nanoid": "^6.0.0"
|
|
199
150
|
},
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
"@types/node": "^26.1.1",
|
|
203
|
-
"esbuild": "^0.28.1",
|
|
204
|
-
"typescript": "^7.0.2",
|
|
205
|
-
"vitest": "^4.1.10"
|
|
151
|
+
"engines": {
|
|
152
|
+
"node": ">=18.0.0"
|
|
206
153
|
},
|
|
207
|
-
"
|
|
154
|
+
"devDependencies": {
|
|
155
|
+
"@types/node": "^26.1.2",
|
|
156
|
+
"typescript": "^7.0.2"
|
|
157
|
+
}
|
|
208
158
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# a3m-vercel-ai
|
|
2
|
+
|
|
3
|
+
**A3M Router provider for Vercel AI SDK** β intelligent cost-based routing with parallel execution, automatic fallback, and 60%+ cost savings.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- π **Automatic Model Selection** β Routes to the cheapest capable provider automatically
|
|
8
|
+
- β‘ **Parallel Ensemble** β Runs multiple providers simultaneously, picks the best result
|
|
9
|
+
- π° **60%+ Cost Savings** β Routes simple queries to free/cheap providers automatically
|
|
10
|
+
- π **Automatic Fallback** β If primary provider fails, routes to next best option
|
|
11
|
+
- π‘οΈ **Circuit Breakers** β Skips degraded providers automatically
|
|
12
|
+
- π **Cost Tracking** β Per-request cost visibility in response metadata
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install a3m-vercel-ai ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createA3MProvider } from 'a3m-vercel-ai';
|
|
24
|
+
import { generateText } from 'ai';
|
|
25
|
+
|
|
26
|
+
const a3m = createA3MProvider();
|
|
27
|
+
|
|
28
|
+
const result = await generateText({
|
|
29
|
+
model: a3m('auto'),
|
|
30
|
+
prompt: 'What is the capital of France?',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(result.text);
|
|
34
|
+
// A3M automatically routes to the cheapest capable provider
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const a3m = createA3MProvider({
|
|
41
|
+
// A3M Router endpoint (default: http://localhost:8787)
|
|
42
|
+
baseURL: process.env.A3M_ROUTER_URL || 'http://localhost:8787',
|
|
43
|
+
|
|
44
|
+
// API key (default: 'not-needed' for local)
|
|
45
|
+
apiKey: process.env.A3M_API_KEY,
|
|
46
|
+
|
|
47
|
+
// Enable parallel ensemble execution
|
|
48
|
+
parallelEnsemble: true,
|
|
49
|
+
|
|
50
|
+
// Number of providers to run in parallel (default: 3)
|
|
51
|
+
parallelCount: 3,
|
|
52
|
+
|
|
53
|
+
// Enable stealth mode for browser automation
|
|
54
|
+
stealth: false,
|
|
55
|
+
|
|
56
|
+
// Cache configuration
|
|
57
|
+
cache: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
ttl: 3600, // 1 hour
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// Provider API keys (if not using environment variables)
|
|
63
|
+
providers: {
|
|
64
|
+
openai: { apiKey: process.env.OPENAI_API_KEY },
|
|
65
|
+
anthropic: { apiKey: process.env.ANTHROPIC_API_KEY },
|
|
66
|
+
groq: { apiKey: process.env.GROQ_API_KEY },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Next.js App Router Example
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// app/api/chat/route.ts
|
|
75
|
+
import { createA3MProvider } from 'a3m-vercel-ai';
|
|
76
|
+
import { streamText } from 'ai';
|
|
77
|
+
|
|
78
|
+
const a3m = createA3MProvider({
|
|
79
|
+
parallelEnsemble: true,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export async function POST(req: Request) {
|
|
83
|
+
const { messages } = await req.json();
|
|
84
|
+
|
|
85
|
+
const result = await streamText({
|
|
86
|
+
model: a3m('auto'),
|
|
87
|
+
messages,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return result.toDataStreamResponse();
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Streaming Response
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const result = await streamText({
|
|
98
|
+
model: a3m('auto'),
|
|
99
|
+
prompt: 'Write a story about a robot...',
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Stream to response
|
|
103
|
+
return result.toDataStreamResponse();
|
|
104
|
+
|
|
105
|
+
// Or accumulate and use
|
|
106
|
+
const { text } = await result.consumeStream();
|
|
107
|
+
console.log(text);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## How It Works
|
|
111
|
+
|
|
112
|
+
A3M Router analyzes each request and routes to the optimal provider:
|
|
113
|
+
|
|
114
|
+
| Request Type | Example | Routed To | Why |
|
|
115
|
+
|-------------|---------|-----------|-----|
|
|
116
|
+
| Simple Q&A | "What is 2+2?" | Groq (free) | Basic mathοΌδΈιθ¦ι«ηΊ§ζ¨‘ε |
|
|
117
|
+
| Code generation | "Write a sorting function" | DeepSeek Coder | δΈη¨δ»£η 樑ε |
|
|
118
|
+
| Complex analysis | "Analyze this legal contract" | Claude 3.5 | ιθ¦ιΏδΈδΈζ |
|
|
119
|
+
| Creative writing | "Write a poem" | GPT-4o | εζδ»»ε‘ |
|
|
120
|
+
|
|
121
|
+
## Cost Savings
|
|
122
|
+
|
|
123
|
+
| Setup | Monthly Cost (100K requests) |
|
|
124
|
+
|-------|-------------------------------|
|
|
125
|
+
| GPT-4o only | $3,000 |
|
|
126
|
+
| Claude only | $2,500 |
|
|
127
|
+
| **A3M Router** | **$800** |
|
|
128
|
+
|
|
129
|
+
## Environment Variables
|
|
130
|
+
|
|
131
|
+
Configure your provider API keys:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# .env.local
|
|
135
|
+
A3M_ROUTER_URL=http://localhost:8787
|
|
136
|
+
OPENAI_API_KEY=sk-...
|
|
137
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
138
|
+
GROQ_API_KEY=gsk_...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Requirements
|
|
142
|
+
|
|
143
|
+
- Node.js 18+
|
|
144
|
+
- Vercel AI SDK 3.0+
|
|
145
|
+
- A3M Router running (or use hosted version)
|
|
146
|
+
|
|
147
|
+
## Start A3M Router
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Install A3M Router
|
|
151
|
+
npm install -g adaptive-memory-multi-model-router
|
|
152
|
+
|
|
153
|
+
# Start the router
|
|
154
|
+
a3m-router serve
|
|
155
|
+
|
|
156
|
+
# Router now running at http://localhost:8787
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|