# Multi-Frontier LLM Consultation & Synthesis Specification (via AIO) > **Purpose:** Use **Artificial Intelligence Optimizer (AIO)** as a single local control gateway (`http://127.0.0.1:14787`) to ask **multiple independent frontier LLMs** for information, analysis, second opinions, and/or advice — then cross-examine disagreements and synthesize a final answer stronger than any individual model alone. > **Pairs With:** [AIO Communication Bus Architecture & HTTP API](session-bus.html) (`127.0.0.1:14786`), which lets different AI coders collaborate on the same goal and feed reviewed plans into implementation. --- ## 0. Why Ask Multiple Frontier LLMs Instead of One? No single frontier model is uniformly strongest across architecture critiques, edge-case spotting, adversarial reasoning, quantitative analysis, and practical judgment. Asking **one** model leaves you exposed to its blind spots, silent assumptions, and tone biases. Routing the same well-structured brief through **AIO** (`http://127.0.0.1:14787`) across **3 to 6 independent frontier models from different model families** (for example Anthropic, OpenAI, Google Gemini, DeepSeek, Qwen, GLM, or Kimi) solves this structurally: - **Consensus separates solid ground from noise:** Where three independent model families agree from first principles, baseline confidence rises. - **Disagreements surface hidden risks:** Where two strong models clash, you uncover subtle trade-offs, ambiguity in your own assumptions, or fragile logic you would never see from a single answer. - **Minority catches beat majority vote:** Often *one* model spots a critical failure mode, cost trap, or edge case that four others glossed over — synthesis lets you keep that catch without adopting that model's weaker opinions. - **One gateway, prepaid-first spend:** Instead of juggling five web tabs and copying text manually, your script or lead AI coder calls one local OpenAI-compatible endpoint (`POST http://127.0.0.1:14787/v1/chat/completions`), spends prepaid capacity before pay-per-use balances, and reconciles exact billed cost afterward. --- ## 1. Pre-Flight Inventory & Prepaid-First Routing Before sending any multi-model consultation batch through AIO: 1. **Discover active models & pricing modes:** - Call `GET http://127.0.0.1:14787/v1/models` to see live enabled models and check which slots are `pricing_mode="prepaid"` with `quota_exhausted=false` vs. metered wallets (`openrouter` / `opencode` pay-per-use). - Run baseline spend checks before dispatching: ```bash aioptimizer balance refresh && aioptimizer balance show ``` 2. **Choose 3–6 diverse frontier slots across distinct families:** - Mix **at least 3 different model lineages** (do not spend budget calling three slight variants of the same checkpoint). - Prefer live **prepaid** seats and allowance pools first for heavy reading/drafting passes, reserving paid pay-per-use wallets cleanly for distinct frontier perspectives not covered by prepaid subscriptions. 3. **Always pin explicit model calls:** - Send HTTP header `X-AIO-Pin-Model: 1` together with `"model": ""` on every `POST http://127.0.0.1:14787/v1/chat/completions` request. That prevents AIO from silently routing onto a fallback slot when you specifically asked for Model X's independent opinion. 4. **Never fail over prepaid calls onto paid wallets silently:** - Keep automatic fallback disabled across billing boundaries (never automatically retry a prepaid call onto a paid pay-per-use model, and never blindly retry a failed or truncated paid call onto another paid model without inspecting why it failed). --- ## 2. Lean Payload Preparation & Smoke-Probe Gate Multi-model fan-outs amplify payload size by the panel size (`N` models × `prompt_tokens`). Prepare cleanly before launching: 1. **Strip formatting noise:** Send clean Markdown or compact plain text only — strip HTML markup, CSS stylesheets, navigation boilerplate, and duplicated headers. Same text can tokenize roughly `1.5x–2x` larger across different tokenizers, so keep context concise and targeted. 2. **Pass the identical brief to every model:** Give every panelist the same facts, explicit constraints, and question framing so differences in output come from model reasoning, not inconsistent prompts. 3. **Run a ~20-token smoke probe first:** Before sending a large dossier to every slot, send a lightweight sanity check (`max_tokens=256` to `1024`, simple prompt asking for a short `READY` line) and verify on **every** slot: - HTTP status `200` - Non-empty `choices[0].message.content` - `finish_reason == "stop"` (not `"length"` or error) - Distinct returned `model` identifiers confirming panel diversity --- ## 3. Reasoning-Budget Hygiene (Preventing Silent Truncation) Reasoning-capable frontier models share `max_tokens` between hidden reasoning tokens and visible response text: - If a model consumes all `max_tokens` on internal thinking, it returns **0 visible characters**, `finish_reason == "length"`, and still bills the full completion allocation. - **Explicit effort caps & headroom:** - On paid OpenRouter reasoning models during bulk review or second-opinion panels, pass `"reasoning": {"effort": "low"}` (raising to medium/high only for deep formal architecture proofs) alongside sufficient output headroom (`max_tokens: 16000` to `24000`). - On prepaid effort-tiered models (`-high` / `-medium` / `-low`), step down to `-medium` or `-low` if `-high` truncates inside hidden thinking. - **Log token & finish telemetry on every response:** Record `status`, `finish_reason`, `prompt_tokens`, `completion_tokens`, `usage.completion_tokens_details.reasoning_tokens` (when provided), and `usage.cost` for every panel response. Never overwrite a usable partial draft with an unchecked retry. --- ## 4. Stage 1 — Independent Parallel Elicitation (Anti-Groupthink) Dispatch the exact same prompt **in parallel** to all `N` chosen frontier models with **zero cross-visibility** (none of the models sees what the others wrote). Require every model to return the same five structured sections so downstream comparison and synthesis stay sharp: 1. **Direct Answer / Core Thesis:** Concrete answer or recommendation upfront (avoid vague hedging). 2. **Key Facts, Evidence & Assumptions:** Explicit factual basis and what is inferred vs. verified. 3. **Trade-Offs & Counter-Arguments:** Strongest arguments against the model's own recommendation. 4. **Blind Spots, Failure Modes & Open Risks:** What breaks first under real load, cost, security, or human constraints (with confidence notes). 5. **Concrete Actionable Changes:** Ranked, specific edits, decisions, or verification checks. Save each raw response separately (`round1__.md`) along with its `finish_reason`, token counts, and `usage.cost`. --- ## 5. Stage 2 — Disagreement Ledger & Optional Cross-Critique Panel Once all Stage 1 responses arrive: 1. **Check spend between rounds:** Run `aioptimizer balance refresh && aioptimizer balance show` before deciding whether a second round is warranted. Simple informational queries or aligned panels can jump directly to Stage 3 synthesis at **$0 extra token cost**. 2. **Build a Disagreement Ledger (no extra LLM call needed):** List: - **High-consensus points** supported independently by 3+ model families - **Direct conflicts** (e.g., Model A recommends Pattern X while Model B warns Pattern X causes Y) - **Unique minority catches** surfaced by only 1 model 3. **Optional Round 2 — Targeted Cross-Critique (for high-stakes architecture or strategy decisions):** - Pick **2 to 4 strongest models** from Stage 1. - Feed each reviewer the condensed Disagreement Ledger (or labeled Round 1 positions) and ask strictly three questions: 1. Which disputes settle cleanly once primary evidence is checked? 2. Which single minority objection from Round 1 is right and should override the majority? 3. Which specific recommendation should be cut, kept, or refined? --- ## 6. Stage 3 — Grounded Synthesis Protocol (Better Than Any Model Alone) Synthesizing is **not** averaging outputs or concatenating five essays into a wall of text. Follow four strict rules (whether performed by a human decision-maker or a lead AI controller): 1. **Verify concrete claims against primary reality:** Before adopting *any* factual claim (API behavior, config path, command flag, benchmark number, or bug report) — even if all five models agreed on it — check actual source files, docs, or tool outputs. Unanimous model agreement never outweighs verified facts on disk. 2. **Preserve high-signal minority catches:** Explicitly test any unique warning raised by just one model; often the highest value of a multi-model panel comes from one model spotting a subtle race condition, legal edge, or security leak. 3. **Decide trade-offs under real constraints:** When models split on valid design alternatives, pick **one coherent direction** tailored to the user's stated goal, budget, and operational environment rather than stitching together contradictory advice. 4. **Emit an explicit Decision & Provenance Report:** - **Synthesized Answer / Final Recommendation** (clear, decisive, directly usable) - **Where Models Agreed vs. Disagreed** (brief summary of conflicts and why each resolved as it did) - **Key Minority Catches Adopted (and Hallucinations Rejected)** - **Panel Telemetry & Billed Spend** (models called, `finish_reason`, verified cost reconciled via `aioptimizer costs show` and `aioptimizer balance show`) --- ## 7. Copy-Paste Specification Prompt & Minimal Python Pattern ### A. Ready-to-Paste AI Orchestrator Prompt (`.md`) Copy or point any capable AI coder / assistant at this block when asking multiple frontier LLMs through AIO: ```text Consult a diverse panel of 3–6 frontier LLMs through local AIO (http://127.0.0.1:14787) on the question/artifact below, cross-check disagreements, verify factual claims against primary sources, and synthesize one final answer stronger than any single model alone. Rules: 1. Check GET http://127.0.0.1:14787/v1/models and run `aioptimizer balance refresh && aioptimizer balance show` first. Prefer live prepaid models (`pricing_mode="prepaid"`, `quota_exhausted=false`) ahead of paid wallets. 2. Pass `X-AIO-Pin-Model: 1` with explicit `"model"` on every `POST http://127.0.0.1:14787/v1/chat/completions` call. Never auto-fallback prepaid onto paid or blindly retry truncated paid calls. 3. Strip boilerplate to minimal plain text / Markdown. Run a 20-token smoke probe (`finish_reason == "stop"`, non-empty content) on every slot before sending full payload. 4. On paid OpenRouter reasoning models use `"reasoning": {"effort": "low"}` + `max_tokens: 16000–24000`; inspect `finish_reason`, `reasoning_tokens`, and `usage.cost`. 5. Run Stage 1 in parallel with zero cross-visibility requiring: Direct Answer, Evidence/Assumptions, Trade-Offs, Blind Spots/Risks, Concrete Recommendations. 6. Build a Disagreement Ledger (plus an optional Round 2 cross-critique if high-stakes disagreements remain, re-checking `balance show` between rounds). 7. Verify concrete factual claims directly against files/tools, preserve valid minority catches, reject hallucinations, and output one cohesive synthesis with model telemetry and reconciled cost (`aioptimizer costs show`). ``` ### B. Minimal Stdlib Python Pattern (Zero External Dependencies) ```python import json import urllib.request AIO_GATEWAY = "http://127.0.0.1:14787" def ask_pinned_model(model: str, system_prompt: str, user_prompt: str, max_tokens: int = 16000) -> dict: payload = { "model": model, "messages": [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}, ], "max_tokens": max_tokens, "reasoning": {"effort": "low"}, } req = urllib.request.Request( f"{AIO_GATEWAY}/v1/chat/completions", data=json.dumps(payload).encode("utf-8"), headers={ "Content-Type": "application/json", "X-AIO-Pin-Model": "1", }, method="POST", ) with urllib.request.urlopen(req, timeout=300) as resp: data = json.loads(resp.read().decode("utf-8")) choice = data["choices"][0] return { "model_returned": data.get("model", model), "finish_reason": choice.get("finish_reason"), "content": choice["message"]["content"], "usage": data.get("usage", {}), } ``` --- ## 8. Pairing Frontier Synthesis With the AIO Communication Bus This specification pairs directly with AIO's native **Communication Bus** (`127.0.0.1:14786` — [read architecture & HTTP reference](session-bus.html)): 1. A **lead AI coder** (or controller session running under Antigravity, Claude Code, or a custom orchestrator) consults multiple frontier LLMs over AIO gateway `127.0.0.1:14787` using this protocol to lock down an architecture decision, editorial strategy, or security review. 2. Once the synthesized plan resolves open risks and disagreements, the lead dispatches clean, file-disjoint work briefs over the **AIO Communication Bus** (`127.0.0.1:14786`) so **multiple different AI coders** execute in parallel toward the same goal and report verified results back deterministically.