# URL/HTML to Markdown Distiller with BM25 Budget Control

> URL/HTML to Markdown Distiller with BM25 Budget Control is a paid API for AI agents from preflight.agentdiet.dev, paid per call via MPP, $0.001/call, status unknown (last checked 2026-11-21).

Fetches and distills a URL or raw HTML into compact, agent-ready Markdown with optional BM25 keyword-focused token budget trimming

## Facts

- Endpoint: POST https://preflight.agentdiet.dev/v1/url-to-markdown?utm_source=zero.xyz
- Price: $0.001/call
- Payment: MPP
- Status: unknown
- Last checked: 2026-11-21
- Activations on Zero: 0
- Provider: preflight.agentdiet.dev
- Website: https://preflight.agentdiet.dev
- Canonical page: https://www.zero.xyz/c/preflight-agentdiet-dev-url-html-to-markdown-distiller-with-bm25-e4181ed9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_0Tnp4Dw2K_tVrUUZpzvMr

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability preflight-agentdiet-dev-url-html-to-markdown-distiller-with-bm25-e4181ed9 -d '<json body>'
```

Example prompt: Distill the content at https://stripe.com/docs/api into clean markdown, focusing on 'authentication headers' and keep it under 500 tokens using budget mode.

## When to prefer this

Choose this endpoint when you need to reduce the token footprint of web content before passing it to an LLM — especially when you want BM25 keyword-focused excerpting to stay within a strict token budget. Prefer it over generic scrapers when you care about compression ratio reporting and LLM cost savings. The budget mode with a focus query is uniquely suited for RAG pipelines and research agents that need only the most relevant portion of a large page. Use the html input when you already have the raw HTML and want to avoid a redundant HTTP fetch.

## Known failure modes

- URL is unreachable or returns non-200 — fetch fails with an error status
- HTML payload is empty or malformed — distillation returns empty or low-quality output
- max_tokens set below 20 — rejected with validation error
- BM25 query provided without mode=budget — query may be ignored
- Rate limit or payment failure — HTTP 402 returned if payment not satisfied
- Target page is JavaScript-rendered SPA — static fetch may miss dynamic content
- Token budget too small relative to page size — output may be truncated aggressively

## How this service works

Distill a URL or raw HTML payload with BM25 budget control (Live x402 v2, IETF MPP & MCP endpoint at https://preflight.agentdiet.dev/v1/url-to-markdown)

## Output

Returns a JSON object containing the distilled content (Markdown text, structured JSON tables/metadata, skeleton outline, or BM25 budget excerpt depending on mode), plus an roi_proof block showing raw vs distilled token counts, compression ratio percentage, tokens saved, and estimated LLM cost saved in USD. Also includes cache hit/miss status, cache latency, and billing metadata.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "url"
 ],
 "properties": {
  "url": {
   "type": "string",
   "minLength": 1,
   "description": "Target webpage URL to fetch and distill (or builtin://stripe-docs)"
  },
  "html": {
   "type": "string",
   "description": "Optional raw HTML string to distill directly without fetching"
  },
  "mode": {
   "enum": [
    "markdown",
    "structured",
    "skeleton",
    "budget"
   ],
   "type": "string",
   "default": "markdown",
   "description": "Distillation mode"
  },
  "query": {
   "type": "string",
   "description": "BM25 focus query when mode=budget"
  },
  "max_tokens": {
   "type": "integer",
   "minimum": 20,
   "description": "Strict token budget ceiling when mode=budget"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "status",
  "roi_proof",
  "data"
 ],
 "properties": {
  "data": {
   "type": "object",
   "description": "Distilled Markdown, structured JSON tables/metadata, skeleton outline, or BM25 budget excerpt."
  },
  "cache": {
   "type": "object",
   "properties": {
    "status": {
     "enum": [
      "HIT",
      "MISS"
     ],
     "type": "string"
    },
    "cache_key": {
     "type": "string"
    },
    "latency_ms": {
     "type": "number"
    }
   }
  },
  "status": {
   "type": "string",
   "description": "Execution status ('ok')"
  },
  "billing": {
   "type": "object",
   "properties": {
    "agent_id": {
     "type": "string"
    },
    "payment_method": {
     "type": "string"
    },
    "fee_charged_usd": {
     "type": "number"
    }
   }
  },
  "roi_proof": {
   "type": "object",
   "properties": {
    "raw_tokens": {
     "type": "integer"
    },
    "tokens_saved": {
     "type": "integer"
    },
    "roi_multiplier": {
     "type": "number"
    },
    "distilled_tokens": {
     "type": "integer"
    },
    "llm_cost_saved_usd": {
     "type": "number"
    },
    "compression_ratio_pct": {
     "type": "number"
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/preflight-agentdiet-dev-url-html-to-markdown-distiller-with-bm25-e4181ed9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from preflight.agentdiet.dev](https://www.zero.xyz/host/preflight.agentdiet.dev/llms.txt)
