Metadata-Version: 2.4
Name: a3m-router
Version: 2.2.1
Summary: Auto-selects cheapest capable LLM from 47+ providers — 70-95% cost savings
License: MIT
Project-URL: Homepage, https://github.com/Das-rebel/a3m-router
Project-URL: Documentation, https://das-rebel.github.io/a3m-router
Project-URL: Repository, https://github.com/Das-rebel/a3m-router
Project-URL: Changelog, https://github.com/Das-rebel/a3m-router/releases
Keywords: llm,routing,openai,proxy,ai-gateway,routellm,litellm,multi-llm,model-selection,cost-optimization,langchain,llamaindex,rag,vector-search,embeddings,parallel,ensemble,router
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Provides-Extra: llamaindex
Requires-Dist: llamaindex>=0.9.0; extra == "llamaindex"
Provides-Extra: qdrant
Requires-Dist: qdrant-client>=1.7.0; extra == "qdrant"
Provides-Extra: weaviate
Requires-Dist: weaviate-client>=4.0.0; extra == "weaviate"
Provides-Extra: adapters
Requires-Dist: langchain>=0.1.0; extra == "adapters"
Requires-Dist: llamaindex>=0.9.0; extra == "adapters"
Requires-Dist: qdrant-client>=1.7.0; extra == "adapters"
Requires-Dist: weaviate-client>=4.0.0; extra == "adapters"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"

# A3M Router Python SDK

**Intelligent LLM routing — auto-selects the cheapest capable model from 47+ providers.**

Routes queries to the best model for your needs — whether it's Groq for simple Q&A ($0.001/1K) or GPT-4o for complex reasoning ($0.15/1K).

## Installation

```bash
pip install a3m-router
```

## Quick Start

```python
from a3m import A3MRouter

router = A3MRouter(base_url="http://localhost:8787")

# Auto-routes to optimal provider
response = await router.chat("What is 2+2?")
# → Routes to Groq, costs ~$0.000001

# See routing decision before executing
decision = await router.route("Explain quantum computing")
print(f"Model: {decision.model}")
print(f"Tier: {decision.tier}")
print(f"Cost: ${decision.cost:.6f}")

# Stream responses
async for token in router.stream_chat("Tell me a story"):
    print(token, end="", flush=True)
```

## Key Features

- **Auto-routing**: Picks the right model based on query complexity, budget, and requirements
- **Cost savings**: 70-95% cheaper than always using premium models
- **47+ providers**: Groq, DeepSeek, GPT-4o, Claude, Mistral, and more
- **Framework adapters**: Drop-in for LangChain, LlamaIndex, Qdrant, Weaviate
- **Health monitoring**: Check provider status and availability
- **Cost analytics**: Track spending and savings

## Framework Adapters

| Adapter | Use Case | Install |
|---------|----------|---------|
| **LangChain** | Chain-based AI workflows | `pip install a3m-router[langchain]` |
| **LlamaIndex** | RAG and document QA | `pip install a3m-router[llamaindex]` |
| **Qdrant** | Vector search + RAG | `pip install a3m-router[qdrant]` |
| **Weaviate** | Vector search + RAG | `pip install a3m-router[weaviate]` |

All adapters:
```bash
pip install a3m-router[all]
```

## Routing Tiers

| Tier | Providers | Cost | When Used |
|------|-----------|------|-----------|
| **free** | Ollama, vLLM | $0 | Local inference |
| **cheap** | Groq, DeepSeek | ~$0.001/1K | Simple Q&A, short code |
| **mid** | GPT-4o-mini, Claude-haiku | ~$0.01/1K | Standard tasks |
| **premium** | GPT-4o, Claude-sonnet | ~$0.15/1K | Complex reasoning |

## API Reference

### A3MRouter

```python
router = A3MRouter(
    base_url="http://localhost:8787",  # A3M Router server URL
    timeout=30.0,                       # Request timeout
)
```

| Method | Description |
|--------|-------------|
| `chat(message)` | Send chat message with auto-routing |
| `route(query)` | Get routing decision (no execution) |
| `route_batch(queries)` | Route multiple queries |
| `stream_chat(message)` | Stream response tokens |
| `models()` | List all available models |
| `health()` | Provider health status |
| `cost_report()` | Cost analytics |

### LangChain Example

```python
from a3m import LangChainAdapter
from langchain.schema import HumanMessage

llm = LangChainAdapter(base_url="http://localhost:8787")
response = llm([HumanMessage(content="What is RAG?")])
```

### LlamaIndex Example

```python
from a3m import LlamaIndexAdapter

llm = LlamaIndexAdapter()
response = llm.complete("Explain transformers")
```

## Server Setup

Start the A3M Router server:

```bash
# Via npm
npx a3m-router serve

# Via Docker
docker-compose up -d
```

Server runs on `http://localhost:8787` by default.

## Links

- **GitHub**: https://github.com/Das-rebel/a3m-router
- **npm Package**: https://www.npmjs.com/package/adaptive-memory-multi-model-router
- **Documentation**: https://das-rebel.github.io/a3m-router

## License

MIT
