{"uid":"cap_wm6OLx7lkmGNElQaTNyp6","slug":"onchain-risk-agentdiet-dev-rag-token-diet-bm25-budget-controlled-url-072d5e0b","name":"RAG Token Diet – BM25 Budget-Controlled URL/HTML Distiller","description":"Distill a URL or raw HTML payload with BM25 budget control (Live x402 v2, IETF MPP & MCP endpoint at https://onchain-risk.agentdiet.dev/v1/rag-token-diet)","url":"https://onchain-risk.agentdiet.dev/v1/rag-token-diet?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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"}}},"responseSchema":{"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"}}}}},"example":null,"exampleRequest":null,"tags":[],"displayCostAmount":"0.001","displayCostAsset":"USD","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"mpp","network":"tempo","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"mpp","network":"tempo","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_yPR8EJh_h1eY7U5dG8UAT","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":"onchain-risk.agentdiet.dev","brandSlug":"onchain-risk-agentdiet-dev-mpp","brandBaseUrl":"https://onchain-risk.agentdiet.dev","brandDocsUrl":null,"whatItDoes":"Fetches a URL or accepts raw HTML and distills it into compact, token-efficient content using BM25 ranking with a strict token budget ceiling, returning Markdown, structured JSON, skeleton outlines, or query-focused excerpts.","exampleAgentPrompt":"Fetch https://stripe.com/docs/payments and distill it down to 800 tokens using budget mode, focused on the query 'payment intents API', so I can ground my answer without blowing my token budget.","exampleUseCases":[{"title":"RAG grounding on tight token budget","prompt":"Distill https://docs.openai.com/api-reference into budget mode with a max of 500 tokens, focused on the query 'function calling', so I can include only the most relevant section in my prompt."},{"title":"Clean Markdown from competitor pricing page","prompt":"Fetch https://anthropic.com/pricing and convert it to clean Markdown — I want all the noise stripped out so I can compare their model prices programmatically."},{"title":"Structured data extraction from raw HTML","prompt":"I've got a raw HTML blob from a scraped product page — can you run it through structured mode and pull out the tables and metadata so I get back clean JSON?"}],"resultDescription":"Returns a status field ('ok'), a data object containing the distilled content (Markdown text, structured JSON tables/metadata, skeleton outline, or BM25-focused excerpt depending on mode), an roi_proof object showing raw vs. distilled token counts, tokens saved, compression ratio percentage, estimated LLM cost saved in USD, and ROI multiplier, plus optional billing and cache hit/miss metadata.","failureModes":["URL is unreachable or returns non-200 → fetch error with status detail","HTML payload is empty or malformed → parsing failure","max_tokens set below minimum of 20 → validation error","BM25 query missing when mode=budget → query required error","Payment not provided or insufficient → HTTP 402 payment required","Rate limit exceeded → 429 response","Invalid mode enum value → schema validation error"],"whenToPreferThis":"Choose this endpoint when you need to ground an AI agent or RAG pipeline on web content but must control token costs — especially when you have a specific focus query (BM25 mode) or a hard token ceiling. It is superior to generic scrapers when you need token-level budget control, compression ROI proof, or multiple output modes (Markdown, structured, skeleton). Prefer it over raw HTML fetching whenever LLM context window cost is a concern.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-21T12:38:55.511Z","isFirstParty":false,"canonicalSlug":"onchain-risk-agentdiet-dev-rag-token-diet-bm25-budget-controlled-url-072d5e0b"}