{"uid":"cap_lB7P2BCIcOJKwmm1Xv4H1","slug":"agentdiet-dev-agentdiet-context-compress-bm25-budget-controlled-web-eff2ef7e","name":"AgentDiet Context Compress — BM25 Budget-Controlled Web Distillation","description":"Distill a URL or raw HTML payload with BM25 budget control (Live x402 v2, IETF MPP & MCP endpoint at https://agentdiet.dev/v1/context-compress)","url":"https://agentdiet.dev/v1/context-compress?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_IGfWWdEISWDEwSqIGYKYj","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":"agentdiet.dev","brandSlug":"agentdiet-dev-mpp","brandBaseUrl":"https://agentdiet.dev","brandDocsUrl":null,"whatItDoes":"Fetches and distills a URL or raw HTML into compact Markdown, structured JSON, skeleton outline, or BM25-focused excerpt within a strict token budget","exampleAgentPrompt":"Distill https://stripe.com/docs/api into clean Markdown using budget mode, focused on the query 'webhook event types', with a max of 500 tokens.","exampleUseCases":[{"title":"Token-budget research before LLM inference","prompt":"Fetch https://openai.com/blog/gpt-4o and distill it in budget mode focused on the query 'multimodal capabilities', keeping it under 300 tokens so I can include it in my next prompt without blowing my context window."},{"title":"Structured extraction from a product page","prompt":"Take this raw HTML from our competitor's pricing page and distill it into structured tables and metadata — I want clean JSON I can compare against our own pricing."},{"title":"Skeleton outline for a long documentation page","prompt":"Grab https://docs.anthropic.com/claude/reference/getting-started-with-the-api and give me a skeleton outline of the page structure so I can quickly navigate to the section about rate limits."}],"resultDescription":"Returns a JSON object with a 'data' field containing the distilled content (Markdown text, structured JSON tables/metadata, skeleton outline, or BM25-scored excerpt depending on mode), an 'roi_proof' object showing raw_tokens, distilled_tokens, tokens_saved, compression_ratio_pct, roi_multiplier, and llm_cost_saved_usd, plus optional cache metadata (HIT/MISS, latency_ms) and billing info (fee_charged_usd).","failureModes":["URL is unreachable or returns non-200 — fetch error with status detail","HTML payload is empty or malformed — distillation returns minimal or empty data field","max_tokens is below the minimum of 20 — validation error","mode=budget used without a query — BM25 scoring may return generic top passage","Page is JavaScript-rendered and content is not in static HTML — distillation may miss dynamic content","x402 payment fails or agent_id is invalid — 402 Payment Required response"],"whenToPreferThis":"Choose this endpoint when you need to shrink web content to fit within an LLM context window before inference, especially when you have a specific topic focus (use budget+query mode for BM25 relevance filtering) or need a strict token ceiling. It is superior to raw scraping when token cost matters, and better than generic summarizers when you need structured output modes (tables, skeleton, Markdown) with transparent ROI metrics showing exactly how many tokens and dollars were saved.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-24T16:59:19.373Z","isFirstParty":false,"canonicalSlug":"agentdiet-dev-agentdiet-context-compress-bm25-budget-controlled-web-eff2ef7e"}