Skip to main content

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 :free variants) — $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 on 429.
  • MCP server (stdio) with fusion_query and fusion_status tools — 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_timeout is raised to ~90s because a fusion run takes 30–60s.
  • Until the package is on PyPI, point command at 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openrouter_fusion_agent-0.1.1.tar.gz (77.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openrouter_fusion_agent-0.1.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file openrouter_fusion_agent-0.1.1.tar.gz.

File metadata

  • Download URL: openrouter_fusion_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 77.5 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

Hashes for openrouter_fusion_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3654ee5e6653c64f4bb932e89bc601aac62b83d39792aa0aaf274c00af5a81ee
MD5 15def281668bba10e7d4830bcb1a74e9
BLAKE2b-256 6d5a028fbc88f142da7e4572de9b3d8282ba2dbe8723838e51a52b790fdfa2bf

See more details on using hashes here.

File details

Details for the file openrouter_fusion_agent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: openrouter_fusion_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.2 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

Hashes for openrouter_fusion_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6af4b460c6cb62a0cc53d85e37b108df9e17fd86a4299487de112f4421da5630
MD5 e1d303035f05b9af07b8c67646c93ecc
BLAKE2b-256 7a9e3e7280156b3dd0e759f40189b9c7a3441d4ba7830bfc4be550193331bd58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page