Skip to main content
Glama
README.md
# nan-council

Multi-AI council — run multiple AI models in parallel, compare, vote, debate.

Send one question, get answers from GPT-4o, Claude, Llama, Gemini, and more simultaneously. See where they agree, where they disagree, and make better decisions.

## Install

```bash
npm install -g nan-council
```

Or use directly:

```bash
npx nan-council
```

## Quick Start

### 1. Add models to your council

```bash
# Add cloud models (need API keys)
nan-council add gpt-4o          # uses $OPENAI_API_KEY
nan-council add claude           # uses $ANTHROPIC_API_KEY
nan-council add gemini           # uses $GOOGLE_API_KEY

# Add local models (free, no API key)
nan-council add llama3           # needs Ollama running
nan-council add deepseek         # needs Ollama running

# Add fast inference
nan-council add groq             # uses $GROQ_API_KEY
```

Models are saved permanently to `~/.nan-council/config.json` — add once, never again.

### 2. Ask the council

```bash
nan-council ask "What's the best way to handle auth in a Node.js API?"
```

All configured models answer in parallel. You see side-by-side responses with agreement analysis.

### 3. Vote on decisions

```bash
nan-council vote "Should we use PostgreSQL or MongoDB?" --options "PostgreSQL,MongoDB"
```

Each model votes with confidence scores and reasoning.

## MCP Server (for Claude Code / AI clients)

nan-council works as an MCP server. Add it to your Claude Code config:

```json
{
  "mcpServers": {
    "nan-council": {
      "command": "npx",
      "args": ["-y", "nan-council", "serve"]
    }
  }
}
```

Then just tell Claude:
- "Add GPT-4o to my council"
- "Ask the council about the best database for this project"
- "Have the council vote on SQL vs NoSQL"
- "Run a debate on monolith vs microservices"

The LLM figures out the provider, model, and API key automatically.

### MCP Tools

| Tool | Description |
|------|-------------|
| `council_add_provider` | Add a model (persists permanently) |
| `council_remove_provider` | Remove a model |
| `council_list_providers` | List configured models |
| `council_ask` | Ask all models in parallel |
| `council_vote` | Structured voting with confidence |
| `council_debate` | Multi-round debate |
| `council_health` | Check provider availability |

## CLI Commands

```bash
nan-council init              # Setup wizard
nan-council add <model>       # Add a model
nan-council remove <model>    # Remove a model
nan-council list              # List configured models
nan-council ask "question"    # Ask the council
nan-council vote "question"   # Structured vote
nan-council models            # List all known models
nan-council health            # Check provider health
nan-council serve             # Start MCP server
```

## Supported Providers

| Provider | Models | API Key Env | Cost |
|----------|--------|-------------|------|
| **OpenAI** | gpt-4o, gpt-4o-mini, o1, o3-mini | `OPENAI_API_KEY` | Paid |
| **Anthropic** | claude-sonnet-4, claude-opus-4, claude-haiku-4.5 | `ANTHROPIC_API_KEY` | Paid |
| **Google** | gemini-2.0-flash, gemini-1.5-pro | `GOOGLE_API_KEY` | Paid |
| **Mistral** | mistral-large, mistral-small | `MISTRAL_API_KEY` | Paid |
| **Groq** | llama-3.1-70b, mixtral-8x7b | `GROQ_API_KEY` | Paid (cheap) |
| **Ollama** | llama3, mistral, phi3, qwen2.5, deepseek | None (local) | Free |

### Don't have any API keys?

Use **Ollama** — it's free and runs locally:

```bash
# Install Ollama: https://ollama.ai
ollama pull llama3.1
ollama pull mistral

nan-council add llama3
nan-council add mistral-local
nan-council ask "Your question here"
```

### Adding custom providers

Drop a `.js` file in `~/.nan-council/providers/`:

```javascript
// ~/.nan-council/providers/my-custom.js
module.exports = {
  name: 'my-custom',
  displayName: 'My Custom LLM',
  capabilities: ['streaming'],
  models: [{ id: 'custom-v1', contextWindow: 4096 }],
  create(config) {
    return {
      async *stream(req) { /* yield { text, done } */ },
      async complete(req) { /* return ProviderResponse */ },
      async healthCheck() { return { ok: true, latencyMs: 0 }; },
      estimateCost() { return 0; },
    };
  }
};
```

## nan-forget Integration

If you have [nan-forget](https://github.com/nanmesh/nan-forget) installed, nan-council automatically:

- Searches prior decisions for relevant context before prompting
- Saves council decisions to long-term memory (provenance: `debate`, 0.85 confidence)
- Tracks model reliability over time

No configuration needed — nan-council detects nan-forget automatically.

## How Consensus Works

### Agreement Detection (automatic with `ask`)
Extracts key phrases from each response, computes overlap similarity, and classifies as:
- **Unanimous** (>50% overlap)
- **Strong** (>30% overlap)
- **Partial** (>15% overlap)
- **Split** (<15% overlap)

### Structured Voting (with `vote`)
Each model votes in JSON format with confidence (1-10) and reasoning. Winner determined by vote count, tie-broken by average confidence.

### Multi-Round Debate (with `debate`)
Models see each other's responses across rounds and can rebut. A synthesizer model combines all perspectives at the end.

## Config

Config is stored at `~/.nan-council/config.json`:

```json
{
  "providers": [
    { "name": "openai", "model": "gpt-4o", "apiKey": "$OPENAI_API_KEY" },
    { "name": "claude", "model": "claude-sonnet-4-20250514", "apiKey": "$ANTHROPIC_API_KEY" },
    { "name": "ollama", "model": "llama3.1", "baseUrl": "http://localhost:11434" }
  ],
  "defaults": {
    "council": ["openai", "claude", "ollama"],
    "timeout": 60000,
    "maxConcurrent": 10
  }
}
```

API keys use `$ENV_VAR` syntax — the actual key is read from your environment at runtime.

## Programmatic API

```typescript
import { runCouncil, detectAgreement } from 'nan-council';

const result = await runCouncil({
  prompt: 'What database should I use?',
  models: ['gpt-4o', 'claude'],
});

const agreement = detectAgreement(result.responses);
console.log(agreement.summary);
```

## License

MIT