Multi-model deliberation agent for OpenRouter Fusion on free models — CLI + MCP server for opencode
Project description
openrouter-fusion-agent
Multi-model deliberation agent for OpenRouter Fusion, running entirely on free models. Provides a CLI and an MCP server that you can plug into opencode (or any MCP client).
Fusion runs a panel of models in parallel (each with web search), a judge compares their answers and returns structured analysis — consensus, contradictions, unique insights, blind spots — and your outer model writes a stronger final answer. OpenRouter ships this with expensive paid defaults; this project reconfigures it with free (:free) models and adds budget-aware safeguards against OpenRouter's free-tier rate limits.
Features
- 100% free models (OpenRouter
:freevariants) — $0 per run. - Two presets: quality (diverse strong panel) and budget (smaller / faster).
- Budget-aware: reads
GET /api/v1/key, blocks on negative balance (HTTP 402), tracks the 50/1000 daily free-request cap, throttles to 20 RPM, retries on429. - MCP server (stdio) with
fusion_queryandfusion_statustools — native for opencode. - CLI one-shot + interactive REPL.
- Typed (mypy strict), tested (pytest), MIT-licensed.
Free model presets
The panel is deliberately family-diverse so models produce less correlated answers.
| Preset | Outer (decides + writes) | Panel (parallel) | Judge (analysis) |
|---|---|---|---|
quality (default) |
qwen/qwen3-next-80b-a3b-instruct:free |
openai/gpt-oss-120b:free, nvidia/nemotron-3-ultra-550b-a55b:free, meta-llama/llama-3.3-70b-instruct:free |
nvidia/nemotron-3-ultra-550b-a55b:free |
budget |
qwen/qwen3-next-80b-a3b-instruct:free |
google/gemma-4-26b-a4b-it:free, nvidia/nemotron-3-nano-30b-a3b:free, openai/gpt-oss-20b:free |
nvidia/nemotron-3-super-120b-a12b:free |
A run costs roughly len(panel) + 2 completions (5 for the default panel).
Free-tier limits (why budget awareness matters)
OpenRouter free models are limited to 20 requests/minute and a daily cap of 50 requests/day if you've purchased < $10 of credits, or 1000/day at ≥ $10 (the calls themselves still cost $0). A negative account balance raises HTTP 402 even on free models. This agent reads GET /api/v1/key to detect is_free_tier and the balance, and enforces the caps so you don't hit hard failures mid-run. Tip: adding ≥ $10 of credits lifts the daily cap to 1000 while keeping every call free.
Installation
Requires Python ≥ 3.11.
# from source
git clone https://github.com/Chumikov/openrouter-fusion-agent
cd openrouter-fusion-agent
uv sync # or: pip install -e ".[dev]"
# or once published to PyPI
uvx openrouter-fusion-agent --help
Set your API key:
export OPENROUTER_API_KEY=sk-or-v1-...
CLI usage
# one-shot deliberation
fusion-agent "Compare ridge, lasso and elastic-net regression. Where does each shine?"
# REPL
fusion-agent
fusion> /status
fusion> Compare the strongest arguments for and against a carbon tax.
fusion> /quit
REPL commands: /status, /force on|off, /panel 1|2|3, /preset quality|budget, /budget <n> (override daily cap), /help, /quit.
Flags: --force on|off (default on — guarantees fusion is invoked), --panel N, --preset quality|budget, --budget N.
opencode integration (MCP)
Add the agent as a local MCP server in your opencode.json (see examples/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"fusion": {
"type": "local",
"command": ["uvx", "openrouter-fusion-agent", "--mcp"],
"enabled": true,
"environment": { "OPENROUTER_API_KEY": "{env:OPENROUTER_API_KEY}" },
"timeout": 10000
}
},
"experimental": { "mcp_timeout": 90000 }
}
Notes:
experimental.mcp_timeoutis raised to ~90s because a fusion run takes 30–60s.- Until the package is on PyPI, point
commandat a local checkout instead:["uv", "run", "--directory", "/path/to/openrouter-fusion-agent", "fusion-agent", "--mcp"] - Restart opencode after editing config (it loads config once at startup).
Optionally drop the example skill from examples/skill/fusion/SKILL.md into .opencode/skills/fusion/SKILL.md so opencode knows when to call fusion automatically.
Then in a session:
use the fusion tool to survey the arguments for and against universal basic income
How it works
your question ─▶ outer model ─calls openrouter:fusion─▶ panel (≤3 free models + web_search)
│
▼
judge (free model + web_search) ─structured analysis─▶ outer model ─▶ final answer
The outer model invokes OpenRouter's openrouter:fusion server tool. The judge returns a structured analysis (consensus / contradictions / partial coverage / unique insights / blind spots) which the outer model consumes to write the final answer. The structured analysis is consumed internally; this agent surfaces it best-effort when OpenRouter echoes it, and always returns the final answer, cost, and which models ran.
Development
uv sync --extra dev
uv run ruff format .
uv run ruff check .
uv run mypy src/fusion_agent
uv run pytest -q
CI runs the same on every push/PR (.github/workflows/ci.yml).
License
MIT © Chumikov
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openrouter_fusion_agent-0.1.0.tar.gz.
File metadata
- Download URL: openrouter_fusion_agent-0.1.0.tar.gz
- Upload date:
- Size: 77.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76c78965ff0275e0aa32477e7272d7c9823dd1825ce9892d9ba078838e287da3
|
|
| MD5 |
888be23bd9cdc63ee14612232122a38e
|
|
| BLAKE2b-256 |
117b8fadb454a899f994f064d255533fc12bd21053c722a05a0b6fe2aecc624c
|
File details
Details for the file openrouter_fusion_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openrouter_fusion_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
484dfebb6feabb9c7f27c926693a4f024d363aa2a2787741d2e9d53ca4271514
|
|
| MD5 |
3cead0c65600419fa657d2b8e1dd81f9
|
|
| BLAKE2b-256 |
2de73f81afff38e35e7d7b994208fe6d885a67824034551425cc71dd4843d720
|