Cost Optimization
~7 min readUpdated: November 2026

MOAT AI Router Architecture: Eliminating 5–8% Gateway Markups on Coding Agents

MOAT AI Router wholesale token pooling diagram showing 0% router fee and 40 to 70 percent cost savings across GLM-5.3, DeepSeek V4.1 Flash, and Kimi K3

MOAT (by Command Code) is a pooled wholesale AI inference membership ($5/mo annual or $10/mo monthly) that replaces 5–8% router markups and 5-hour/weekly rate caps with wholesale pricing across 105 full-weight models. By pooling member volume, MOAT discounts DeepSeek V4.1 Flash 60% and GLM-5.3 Flash 70%, pairing cleanly with Smoke Monkey Harness multi-agent loops.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

MOAT AI Router Architecture: Eliminating 5–8% Gateway Markups on Coding Agents: MOAT (by Command Code) is a pooled wholesale AI inference membership ($5/mo annual or $10/mo monthly) that replaces 5–8% router markups and 5-hour/weekly rate caps with wholesale pricing across 105 full-weight models. By pooling member volume, MOAT discounts DeepSeek V4.1 Flash 60% and GLM-5.3 Flash 70%, pairing cleanly with Smoke Monkey Harness multi-agent loops. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Examplemoat-cost-optimized-agent.ts
moat-cost-optimized-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Route Explore/Plan loops to wholesale GLM-5.3 and Edit/Verify loops to DeepSeek V4.1 Flash
const architectAgent = createAgent({
agentId: 'moat-architect',
provider: 'openai',
baseUrl: process.env.MOAT_BASE_URL ?? 'https://api.commandcode.ai/moat/v1',
apiKey: process.env.MOAT_API_KEY ?? '',
model: 'z-ai/glm-5.3',
workspacePath: process.cwd(),
tools: ['filesystem', 'search', 'git'],
permission: 'ask-default',
});
const workerAgent = createAgent({
agentId: 'moat-flash-worker',
provider: 'openai',
baseUrl: process.env.MOAT_BASE_URL ?? 'https://api.commandcode.ai/moat/v1',
apiKey: process.env.MOAT_API_KEY ?? '',
model: 'deepseek/deepseek-v4.1-flash',
workspacePath: process.cwd(),
tools: ['filesystem', 'terminal', 'search'],
permission: 'ask-default',
});
for (const a of [architectAgent, workerAgent]) {
a.on('permission.required', (event) => {
const allowed = ['read_file', 'write_file', 'grep', 'glob', 'git_diff'];
a.resolvePermission(
event.data.toolCallId,
allowed.includes(event.data.toolName) ? 'allow' : 'deny'
);
});
}
async function runCascadedTask() {
const plan = await architectAgent.run('Design TypeScript migration plan in PLAN.md');
const exec = await workerAgent.run(`Execute migration steps from PLAN.md (${plan.status})`);
console.log('Execution result:', exec.status);
}
runCascadedTask().catch(console.error);
Video Guides

Watch: Related Video Guides

OpenRouter Alternative: 10 AI Gateways and Where Their Fee Hides

OpenRouter vs LiteLLM: Pay 5% or Host It Yourself? (2026)

What Is MOAT? Wholesale Token Pooling vs. Traditional LLM Routers

MOAT (by Command Code) is a pooled wholesale inference membership ($5/month billed yearly at $60, or $10/month monthly) that gives developers and teams access to 105 full-weight models at 40%–70% off list price with zero router markup. Unlike consumer coding plans, MOAT enforces no 5-hour or weekly usage caps.

Autonomous coding harnesses burn tokens asymmetrically: reading large repositories, replaying tool outputs, and running verify-recover cycles easily consume 10M–100M tokens per week—primarily cached input tokens. Traditional gateways charge a 5–8% platform fee on top of list API rates and leave teams picking among dozens of inconsistent providers where silent weight quantization breaks JSON tool schemas.

MOAT Wholesale Member Pricing vs. List Rates (per 1M Tokens)

ModelMOAT InputList InputMOAT OutputList OutputMOAT Cache ReadList Cache ReadDiscount
Z.ai: GLM-5.3 Flash$0.045$0.15$0.15$0.50$0.009$0.0370%
Z.ai: GLM-5.3$0.49$1.40$1.54$4.40$0.091$0.2665%
DeepSeek V4.1 Flash (Off-peak)$0.06$0.15$0.24$0.60$0.0012$0.00360%
inclusionAI: Ling 3.1 Flash 1019$0.12$0.30$0.36$0.90$0.024$0.0660%
inclusionAI: Ling 3.1 Flash$0.15$0.30$0.45$0.90$0.03$0.0650%
Moonshot AI: Kimi K3$1.80$3.00$9.00$15.00$0.18$0.3040%

Break-Even Math & Prompt-Cache Economics for Coding Loops

On a representative 60% DeepSeek V4.1 Flash and 40% GLM-5.3 agent workload, MOAT breaks even once monthly list spend hits just $9/month. At $200/month in list API usage ($2,400/year), wholesale discounts reduce token spend to $912/year ($576 Flash + $336 GLM-5.3), yielding $1,428 net annual savings after the $60 membership.

Look at the cache read column above: in long-horizon Smoke Monkey Harness sessions where system + repository context + tool schemas repeat across 20–50 tool turns, cache hits dominate billing. DeepSeek V4.1 Flash's $0.0012 per 1M cached tokens (60% off $0.003) and GLM-5.3 Flash's $0.009 (70% off $0.03) make multi-agent Explore and Verify passes orders of magnitude cheaper than frontier closed APIs.

Membership Tiers: Goat vs. MOAT vs. Standard Aggregators

DimensionStandard Aggregator (e.g. 5–8% Fee)Command Code Goat ($10/mo)MOAT Membership ($5/mo yr)
Included / Rate StructureList price + 5–8% router fee$10/mo usage -> $100 cap, then listWholesale 40–70% off, 0% fee
5-Hour / Weekly Rate LimitsProvider-dependentYes (5-hour + weekly)None (unlimited spend)
Model Weight GuaranteeVaries across unverified hostsBenchmarked full weights105 benchmarked full-weight models
Team ScalingPer-seat + markupSingle developer1 dev or full team ($500–$50K/mo)

Configuring Cascaded Cost-Aware Routing in Smoke Monkey Harness

Maximize wholesale savings in Smoke Monkey Harness by splitting planning, execution, and verification across price tiers rather than sending every grep and lint check to a flagship reasoning model.

bash
# Quick CLI check to estimate monthly agent savings before switching endpoints
curl -s https://api.commandcode.ai/moat/v1/models \
  -H "Authorization: Bearer $MOAT_API_KEY" | jq '.data[:5] | .[].id'
  1. Cache-Stable System Prompts: Keep MCP tool definitions and project guidelines static at the top of the message array so consecutive tool calls hit $0.0012–$0.009/1M cache read rates.
  2. Tiered Model Cascade: Run initial architectural planning and final PR diff review on GLM-5.3 ($0.49/$1.54 per 1M), while routing file-search, test-fix iterations, and unit-test generation to DeepSeek V4.1 Flash ($0.06/$0.24) or GLM-5.3 Flash ($0.045/$0.15).
  3. Local Fallback Hybridization: Pair MOAT wholesale cloud calls with local Ollama or vLLM weights inside Smoke Monkey Canvas when handling sensitive air-gapped credentials.

Avoid Mid-Run Rate-Limit Stalls

Consumer $20/mo coding subscriptions throttle heavy autonomous loops via rolling 5-hour windows. Routing batch agent jobs through MOAT's uncapped wholesale tier prevents half-edited working trees from stalling mid-verification.

Google Search Questions & Answers

Frequently Asked Questions

Q:How does MOAT offer 40% to 70% discounts without degrading model quality?

MOAT pools token volume from its member base into hundreds of trillions of tokens to negotiate wholesale provider rates, while benchmarking every listed endpoint to ensure full weights without silent quantization.

Q:What is the break-even spend for MOAT's $5/month yearly membership?

At an average 62% discount on a 60% DeepSeek V4.1 Flash / 40% GLM-5.3 workload, MOAT pays for its $60/year ($5/month) membership once your list-price usage exceeds roughly $9 per month.

Q:Does MOAT impose 5-hour or weekly usage limits like consumer coding plans?

No. MOAT has zero 5-hour, weekly, or monthly token caps and charges 0% router fees, scaling from single developers to teams spending $500 to $50,000 per month.

Q:Which models carry the steepest wholesale discounts on MOAT?

Listed savings include 70% off Z.ai GLM-5.3 Flash ($0.045 in / $0.15 out), 65% off GLM-5.3 ($0.49 in / $1.54 out), 60% off DeepSeek V4.1 Flash ($0.06 in / $0.24 out) and Ling 3.1 Flash 1019, 50% off Ling 3.1 Flash, and 40% off Kimi K3 across 105 total models.

Q:How do I use MOAT with Smoke Monkey Harness?

Configure createAgent with provider: 'openai', baseUrl pointing to your MOAT OpenAI-compatible gateway, and assign high-volume worker roles to DeepSeek V4.1 Flash or GLM-5.3 Flash.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness