🧠

## Intelligent LLM Routing

Analyzes query complexity and routes to the cheapest capable model. Code queries go to code models. Simple queries use budget providers. Premium models only when needed.

💰

## Cost Optimization

Save 50-80% on API costs. Route simple queries to free tiers (Ollama, CommandCode) or cheap providers (Groq $0.59/1M tokens). Real-time cost analytics dashboard.

🔄

## Smart Fallback & Retry

When a provider fails, automatically retry with the next best option. Circuit breaker pattern keeps your app resilient. Zero downtime.

📊

## Real-time Analytics

Monitor spending across all providers in real-time. Set budgets. Get alerts. Cost analytics with savings reports. Never get surprised by an API bill again.

🔒

## Security Guardrails

Built-in prompt injection detection, PII redaction, content filtering, and rate limiting. Production-ready security out of the box.

⚡

## Semantic Cache

Trigram Jaccard similarity cache eliminates redundant API calls. Batch processing with automatic rate limiting for high-throughput applications.

## LLM Provider Pricing Tiers

39 providers from free to premium. Always pick the cheapest capable option.

### Free Tier

$0 / 1M tokens

- CommandCode
- Ollama (local)
- LM Studio
- vLLM

### Budget Tier

$0.59 - $0.60 / 1M tokens

- Groq (Llama 3.3 70B)
- Cerebras (Llama 3.3 70B)

### Mid Tier

$1.50 - $2.80 / 1M tokens

- DeepSeek
- Mistral
- MiniMax
- Qwen / GLM-4

### Premium Tier

$10 - $30 / 1M tokens

- OpenAI (GPT-4o)
- Anthropic (Claude)
- Google (Gemini)

## Quick Start: LLM Routing in 30 Seconds

One-line installation, instant routing. Drop-in replacement for api.openai.com.

    # Install
    npm install adaptive-memory-multi-model-router

    # Start the OpenAI-compatible proxy
    npx a3m-router serve
    # Now listening on http://localhost:8787/v1

    # Or use programmatically
    const { createA3MRouter } = require('adaptive-memory-multi-model-router');
    const router = createA3MRouter();
    const result = await router.route("Explain quantum computing");
    console.log(result.primary_model); // "groq/llama-3.3-70b" (cheapest capable)
    console.log(result.savings); // "$0.024 saved vs GPT-4"

## Frequently Asked Questions

### What is A3M Router?

A3M Router is an OpenAI-compatible proxy that analyzes each LLM query and routes it to the cheapest capable provider. It supports 39 providers including Groq, Cerebras, OpenAI, Anthropic, DeepSeek, and free local models via Ollama. Drop-in replacement for api.openai.com.

### How much can I save with A3M Router?

A3M Router saves 50-80% on LLM API costs by routing simple queries to cheap or free providers (Groq at $0.59/1M tokens, Cerebras at $0.60/1M tokens, or free via Ollama/CommandCode) while only using premium models like GPT-4 or Claude when query complexity requires it.

### Is A3M Router free?

Yes, A3M Router is MIT-licensed open source software. It's free to use. You only pay for the underlying LLM API calls you route through it, and A3M Router minimizes those costs by selecting the cheapest capable provider.

### How do I get started with A3M Router?

Install with `npm install adaptive-memory-multi-model-router`, then run `npx a3m-router serve` to start the OpenAI-compatible proxy on port 8787. Point your existing OpenAI SDK base URL to http://localhost:8787/v1 and you're done.

### What LLM providers does A3M Router support?

39 providers including OpenAI, Anthropic (Claude), Google (Gemini), Groq, Cerebras, DeepSeek, Mistral, Fireworks, Together AI, Perplexity, Cohere, xAI (Grok), Ollama, OpenRouter, and more. Free options include CommandCode, Ollama, LM Studio, and vLLM.

### How does A3M Router compare to LiteLLM?

A3M Router focuses on intelligent cost-based routing with semantic caching, guardrails, and real-time cost analytics built in. Unlike generic proxy tools, it actively analyzes query complexity to pick the cheapest capable model. Zero config needed for basic usage.