---
name: route-anything
description: Polymorphic 5-domain cost-arbitrage and anti-429 failover router for AI agents (LLM inference, GPU spot compute, multimodal generation, B2B lead enrichment, and FX/logistics) with hard max_cost_micros budget caps, BYOK fallback, $0 unbilled misses, and Zero Trace Resale.
---

# Route-Anything — AI Agent Integration Manual (`https://route.fastmesh.dev`)

Use Route-Anything whenever an agent needs the lowest-cost verified execution across multiple providers without risking HTTP `429` outages, hidden surcharges, fake-200 bot walls, or runaway spend.

- **Remote MCP Endpoint**: `https://route.fastmesh.dev/mcp` (JSON-RPC 2.0, 4 flat tools)
- **REST Base URL**: `https://route.fastmesh.dev`
- **OpenAPI Spec**: `https://route.fastmesh.dev/openapi.json`
- **Treg Hub Tool**: `route-anything` (`0%` seller commission)
- **Zero Trace Resale**: Caller payloads, keys, and receipts are never resold or used for model training. Public traces redact upstream vendor identities and secrets.

---

## 1. Remote MCP Integration (`/mcp`)

Route-Anything exposes 4 flat O(1) tools over JSON-RPC 2.0 at `https://route.fastmesh.dev/mcp`:

| Tool Name | Purpose | Billing |
|---|---|---|
| `route_domains` | List all 5 domains, unit pricing floors, surcharge rules, and cache policies | `$0` |
| `route_quote` | Cost-sorted dry-run arbitrage quote with hidden surcharge normalization | `$0` |
| `route_execute` | Execute cheapest-verified-hit waterfall with anti-429 failover and receipt | Metered up to `max_cost_micros` (`$0` on miss/422/fake-200) |
| `route_byok_register` | Store encrypted write-only customer provider key (`0%` routing markup) | `$0` |

### MCP Discovery (`tools/list`)

```bash
curl -fsSL -X POST "https://route.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
```

### MCP Tool Call (`route_execute`)

```bash
curl -fsSL -X POST "https://route.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ROUTE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "route_execute",
      "arguments": {
        "domain": "llm_inference",
        "task": "Extract revenue and operating margin from quarterly report as JSON",
        "params": {"tokens": 1800, "min_quality": "A"},
        "max_cost_micros": 15000,
        "allow_managed_fallback": true,
        "verify": true,
        "confirm": false
      }
    }
  }'
```

---

## 2. REST API Integration (`/api/route`, `/api/quote`, `/api/byok/keys`)

### 2.1 Dry-Run Arbitrage Quote (`$0`)

```bash
curl -fsSL -X POST "https://route.fastmesh.dev/api/quote" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "gpu_compute",
    "task": "1x H100 80GB spot batch inference",
    "params": {"gpu_model": "H100_80GB", "gpu_hours": 1, "min_vram_gb": 80},
    "max_cost_micros": 3000000
  }'
```

### 2.2 Execute Verified Route (`POST /api/route`)

```bash
curl -fsSL -X POST "https://route.fastmesh.dev/api/route" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ROUTE_API_KEY" \
  -d '{
    "domain": "b2b_enrichment",
    "task": "Enrich engineering leadership contact for acme-robotics.example",
    "params": {"company_domain": "acme-robotics.example", "role": "VP Engineering"},
    "max_cost_micros": 25000,
    "allow_managed_fallback": true,
    "verify": true,
    "confirm": true
  }'
```

### 2.3 Register Write-Only Encrypted BYOK Key (`0%` Markup)

```bash
curl -fsSL -X POST "https://route.fastmesh.dev/api/byok/keys" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ROUTE_API_KEY" \
  -d '{
    "tenant_id": "tenant_acme",
    "domain": "llm_inference",
    "provider_alias": "primary_openai_compat",
    "endpoint_url": "https://api.provider.example/v1/chat/completions",
    "api_key": "sk-live-your-key"
  }'
```

- Private/loopback/link-local URLs (`127.0.0.1`, `10.0.0.0/8`, `169.254.169.254`, `192.168.0.0/16`) are blocked by SSRF guards before any key decryption occurs.
- When your BYOK key hits HTTP `429 Retry-After` or quota exhaustion:
  - `allow_managed_fallback: true` seamlessly fails over to the managed pool within `max_cost_micros`.
  - `allow_managed_fallback: false` halts cleanly and charges `$0`.

---

## 3. Domain Parameter Quick Reference

| Domain | Required `task` | Common `params` | Cache Policy |
|---|---|---|---|
| `llm_inference` | Prompt or structured extraction instruction | `tokens`, `min_quality`, `model_tier` | `TTL_NEVER = -1` (live) |
| `gpu_compute` | Workload spec | `gpu_model`, `gpu_hours`, `min_vram_gb`, `spot_allowed` | `TTL_NEVER = -1` (live) |
| `multimodal_gen` | Generation prompt or script | `modality` (`image`/`video`/`voice_tts`), `resolution`, `duration_s`, `characters` | `TTL_NEVER = -1` (live) |
| `b2b_enrichment` | Company domain, person, or role target | `company_domain`, `role`, `country` | ArchiveCache 7d–30d (`10%` repeat) |
| `fx_logistics` | Currency corridor or shipment lane | `amount_usd`, `source_currency`, `target_currency`, `weight_kg`, `origin_country`, `dest_country`, `residential` | `TTL_NEVER = -1` (live) |

---

## 4. Safety, Billing & Verification Invariants

1. **Hard `max_cost_micros` Cap**: `1 USD = 1,000,000 micros`. If the cheapest viable provider exceeds `max_cost_micros`, dispatch is blocked pre-flight and `$0` is billed.
2. **Unbilled `422` Junk Rejection**: Empty inputs, `"N/A"`, `"null"`, or invalid URLs return HTTP `422` at `$0` without hitting upstream providers.
3. **`$0` on Empty / Miss / Fake-200 / Outage**: HTML challenge pages masquerading as HTTP `200`, empty payloads, and provider `429`/`503` failures auto-skip or fail over and never bill a miss.
4. **Verification & Consensus**:
   - `verify: true`: runs deterministic chained schema/format verification before billing.
   - `confirm: true`: cross-checks 2 independent providers for consensus on high-stakes lookups.
5. **Signed Savings Receipt**: Every successful response returns `baseline_cost_micros`, `actual_cost_micros`, `saved_micros`, `savings_pct`, `receipt_sha256`, `redacted_trace`, and `zero_trace_resale_attestation`.

---

## 5. Treg Hub CLI One-Liner (0% Commission)

```bash
treg call route-anything --data '{"domain":"fx_logistics","action":"quote","task":"USD to EUR 10000 wire + 5kg parcel","max_cost_micros":35000}'
```

## 6. Prepaid Credit Packs (Creem Card Checkout)

- **Free BYOK Tier**: `$0` (`0%` routing markup on your own keys)
- **Starter (`prod_route_starter_19`)**: `$19` for `19,000,000` micros
- **Growth (`prod_route_growth_79`)**: `$79` for `85,000,000` micros
- **Scale (`prod_route_scale_249`)**: `$249` for `280,000,000` micros

Support: `routing@fastmesh.dev`
