# Cloud-FinOps-Arbitrage — Agent Skill Specification

> **Service:** Cloud-FinOps-Arbitrage (`https://finops.fastmesh.dev`)
> **Purpose:** 4-stage automated cloud and AI infrastructure FinOps engine combining exact Python `Decimal` spend auditing, polite SSRF-guarded upstream Pareto benchmarking, reserved/spot/multi-team quota pool modeling, and executable JSON/YAML multi-provider routing policy compilation.
> **Live Rate Cards Baseline:** `2026-12-02T05:40:36Z` (35+ providers, 469 OpenRouter models catalogued, 19 live-verified HTTP 200 public probe targets).
> **Guarantees:** **Zero Savings = $0 Fee** (`billable_usd == "0.00"`, `charge_micros == 0` on zero/negative net savings or invalid input) | **BYOK Zero-Persistence & Zero Customer Bill Resale Pledge** (caller API keys and raw bills are never written to disk, SQLite, logs, cache, or receipts).
> **Contact:** `finops@fastmesh.dev` | Ops: `ops@fastmesh.dev`

## Discovery & Machine Endpoints

- **Health Check:** `GET https://finops.fastmesh.dev/health`
- **OpenAPI 3.1 Schema:** `GET https://finops.fastmesh.dev/openapi.json`
- **AI Crawler Index:** `GET https://finops.fastmesh.dev/llms.txt`
- **XML Sitemap:** `GET https://finops.fastmesh.dev/sitemap.xml`
- **24 SEO/GEO Calculators Hub:** `GET https://finops.fastmesh.dev/seo_geo/`
- **MCP JSON-RPC 2.0 Endpoint:** `POST https://finops.fastmesh.dev/mcp`

## Five Verified Spend Arbitrage Categories

1. **LLM Inference & Embeddings (`llm_inference` — 69.88% spread: `$16.0000 -> $4.8200 / 1M` blended):** Flagship proprietary (`openai/gpt-6.2-astra-pro`, `anthropic/claude-fable-5.2` at `$8.0000`/`$40.0000`) vs tiered `google/gemini-4-hydrogen` (`$1.5000`/`$7.5000`), `anthropic/claude-4.5-sonnet`, `anthropic/claude-haiku-5.5`, 95%–97.5% prompt caching, 50% async batch, Groq LPU (`$0.1500`/`$0.6000`), Fireworks, Together, and DeepInfra (`$0.0900`/`$0.1800`); embeddings `$0.1300 -> $0.0200/1M`.
2. **GPU Compute Pools (`gpu_compute` — 66.06% spread: `$10.0767 -> $3.4200 / GPU-hr` H100):** AWS/GCP/Azure on-demand H100 (`$6.8800`–`$12.2900`), H200 (`$7.9100`–`$10.8500`), B200 (`$14.2400`), A100-80GB (`$5.1200`), L40S (`$1.8610`), A10G (`$1.0060`) vs Lambda (`$3.9900` H100 / `$4.9900` B200), RunPod Secure (`$2.6900` H100 / `$3.5900` H200 / `$1.1200` L40S), CoreWeave (`$6.1600` H100 `$0` egress), Vast (`$1.8800`), and AWS 1yr/3yr RIs.
3. **Object Storage & CDN Egress (`storage_egress` — 87.31% spread: `$0.1970 -> $0.0250 / GB` blended):** AWS S3 (`$0.0230/GB-mo` + `$0.0900/GB` egress), GCS (`$0.1200/GB`), Azure Blob (`$0.0870/GB`) vs Cloudflare R2 (`$0.0150/GB-mo` + `$0.00` egress), Backblaze B2 (`$0.00695/GB-mo` + `$0` up to 3x stored), Wasabi (`$0.00799/GB-mo`), and Bunny CDN Volume (`$0.0050/GB`).
4. **Managed Databases & Vector Stores (`vector_db` — 68.69% spread: `$1,485.00 -> $465.00 / mo`):** Pinecone Serverless (`$16/M` RUs) + AWS OpenSearch 4-OCU floor (`$700.80/mo`) + RDS `db.r6g.xlarge` (`$367.92/mo`) vs Qdrant Cloud (`$115/mo` unlimited queries), Turbopuffer (`$85/mo` object ANN), Neon (`$0.106/CU-hr`, `$0` idle), and Supabase Pro (`$25/mo` base).
5. **B2B Enrichment & Web Scraping APIs (`b2b_enrichment_scrape` — 69.03% spread: `$134.0000 -> $41.5000 / 1K` blended):** ZoomInfo (`$380/1K`), Clearbit (`$65/1K`), Firecrawl JSON (`$19/1K`), Bright Data (`$3/1K`) vs Treg/Monid 0%-markup waterfall (`$28/1K` B2B / `$1.20–$1.50/1K` tools), Jina Reader (`$0.20/1K`), Exa Contents (`$1.00/1K`), Diffbot (`$0.90–$1.20/1K`), and Apify (`$2.30/1K`).

## REST API Quickstart (4-Stage Pipeline)

### Stage 1: Spend Diff Audit (`POST /v1/finops/audit-spend`)

Ingests AWS CUR, GCP, Azure, or custom CSV/JSON bills with exact `Decimal` attribution and detects waste flags.

```bash
curl -sS -X POST https://finops.fastmesh.dev/v1/finops/audit-spend \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [
      {"category": "storage_egress", "provider": "aws_s3", "sku": "s3_standard_storage", "storage_gb": 50000, "unit_price_usd": "0.0230", "monthly_spend_usd": "1150.00"},
      {"category": "storage_egress", "provider": "aws_s3", "sku": "s3_internet_egress", "egress_gb": 100000, "unit_price_usd": "0.0900", "monthly_spend_usd": "8350.00"}
    ]
  }'
```

### Stage 2: Upstream Pareto Benchmark (`POST /v1/finops/benchmark-upstreams`)

Executes polite low-frequency public HTTPS/REST/DoH/MCP probes (strict SSRF guard) or evaluates paired offline latency/availability/cost samples to compute the Pareto frontier and sign `scorecard_sha256`.

```bash
curl -sS -X POST https://finops.fastmesh.dev/v1/finops/benchmark-upstreams \
  -H "Content-Type: application/json" \
  -d '{
    "category": "llm_inference",
    "mode": "offline",
                "targets": [
      {"provider": "openai_gpt_6_2_sol_pro", "p50_ms": 540, "p95_ms": 1350, "availability_pct": "99.9", "unit_cost_usd": "2.0000"},
      {"provider": "groq_gpt_oss_120b", "p50_ms": 180, "p95_ms": 420, "availability_pct": "99.7", "unit_cost_usd": "0.1500"},
      {"provider": "deepinfra_deepseek_v4_1_flash", "p50_ms": 340, "p95_ms": 820, "availability_pct": "99.6", "unit_cost_usd": "0.0900"}
    ]
  }'
```

### Stage 3: Pool & Multi-Team Chargeback Modeler (`POST /v1/finops/pool-model`)

Models 1-year/3-year GPU reservations, spot hybrids, volume discount cliffs, and exact `Decimal` largest-remainder penny splitting (`sum(team_allocations) == pool_total_cost`).

```bash
curl -sS -X POST https://finops.fastmesh.dev/v1/finops/pool-model \
  -H "Content-Type: application/json" \
  -d '{
    "category": "gpu_compute",
    "sku": "H100-80GB",
    "monthly_baseline_usd": "40179.20",
    "commitment_type": "gpu_reserved_3yr_spot_blend",
    "teams": [
      {"team_id": "core_inference", "weight": "45"},
      {"team_id": "post_training", "weight": "35"},
      {"team_id": "eval_qa", "weight": "20"}
    ]
  }'
```

### Stage 4: Full Arbitrage Compiler (`POST /v1/finops/compile-arbitrage`)

Executes the full 4-stage pipeline and returns monthly/annual USD savings, payback days, deployable JSON + YAML + OpenAI-compatible routing policy with circuit breakers, `receipt_sha256`, and billing receipt (`billable_usd: "0.00"` when `net_monthly_savings_usd <= 0`).

```bash
curl -sS -X POST https://finops.fastmesh.dev/v1/finops/compile-arbitrage \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [
      {"category": "llm_inference", "provider": "openai", "sku": "openai/gpt-6.2-astra-pro", "monthly_units": 1500, "unit": "1m_input_tokens", "unit_price_usd": "8.0000", "monthly_spend_usd": "12000.00"},
      {"category": "llm_inference", "provider": "openai", "sku": "openai/gpt-6.2-astra-pro", "monthly_units": 500, "unit": "1m_output_tokens", "unit_price_usd": "40.0000", "monthly_spend_usd": "20000.00"}
    ]
  }'
```

## MCP JSON-RPC 2.0 Integration (`POST /mcp`)

Supported JSON-RPC 2.0 methods: `initialize`, `notifications/initialized`, `ping`, `tools/list`, `tools/call`.

Exposed MCP tools (5):
1. `finops_audit_spend` — Stage 1 CSV/JSON bill diff & waste attribution.
2. `finops_benchmark_upstreams` — Stage 2 SSRF-guarded live/offline Pareto benchmarking + SHA-256 scorecard.
3. `finops_pool_model` — Stage 3 reserved/spot commitment & exact penny multi-team quota slicing.
4. `finops_compile_arbitrage` — Stage 4 full pipeline compiling deployable JSON/YAML/OpenAI-compat routing policies.
5. `finops_health` — Service health, loaded rate-card version, and invariant check.

### Discover Tools (`tools/list`)

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

### Example `tools/call`

```bash
curl -sS -X POST https://finops.fastmesh.dev/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "finops_compile_arbitrage",
      "arguments": {
        "line_items": [
          {"category": "storage_egress", "provider": "aws_s3", "sku": "s3_internet_egress", "storage_gb": 50000, "egress_gb": 100000, "monthly_spend_usd": "9500.00"}
        ]
      }
    }
  }'
```

## Security, Privacy & Fixed-Fee Prepaid Packs

- **Strict SSRF Guard:** Only public `http`/`https` endpoints are probed. Loopback (`127.0.0.1`, `::1`), RFC1918 private networks, link-local / cloud metadata (`169.254.169.254`), non-HTTP schemes, and private DNS resolutions are rejected with HTTP `422` and `$0` charge.
- **BYOK Zero-Disk-Persistence:** Caller BYOK headers and keys are redacted in memory and never written to disk, SQLite, logs, cache, or receipts.
- **Zero Savings = $0 Fee:** Invalid `422` inputs, SSRF blocks, fake-200 rejections, and already-optimal bills (`net_monthly_savings_usd <= 0`) strictly emit `billable_usd: "0.00"` and `charge_micros: 0`.
- **Fixed-Fee Prepaid Creem Packs (`https://finops.fastmesh.dev/#pricing`):**
  - **FinOps Audit (`sku_f07_finops_audit_149`):** `$149` one-time flat fee — `500` non-expiring runs (`$0.2980`/run).
  - **Scale Engineering (`sku_f07_scale_engineering_399`):** `$399` one-time flat fee — `2000` non-expiring runs (`$0.1995`/run).
  - **Enterprise FinOps Desk (`sku_f07_enterprise_finops_desk_999`):** `$999` one-time flat fee — `7500` non-expiring runs (`$0.1332`/run).
  - Independent engineering software (0% savings split, 0% commission, 10% repeat-tenant `ArchiveCache` rate).
- **Marketplace Bridges:** Treg Hub 0%-commission black-box recipe (`cloud-finops-arbitrage`, `$0.50` cap, `$0` on zero savings/failure) and Causal Bazaar public hand `hand_f07_cloud_finops_arbitrage_v1` (`price_micros: 500000`, `repeat_price_micros: 50000`, `max_price_micros: 2000000`).
