{"uid":"cap_88LzGVH2W_6X3bPEf4t9_","slug":"company-enrich-agentdiet-dev-web-page-html-token-optimizer-with-bm25-95033d8f","name":"Web Page & HTML Token Optimizer with BM25 Budget Control","description":"Distill a URL or raw HTML payload with BM25 budget control (Live x402 v2, IETF MPP & MCP endpoint at https://company-enrich.agentdiet.dev/v1/token-optimizer)","url":"https://company-enrich.agentdiet.dev/v1/token-optimizer?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_orR_NyGn7keVPv_a1Dm7D","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":"company-enrich.agentdiet.dev","brandSlug":"company-enrich-agentdiet-dev-mpp","brandBaseUrl":"https://company-enrich.agentdiet.dev","brandDocsUrl":null,"whatItDoes":"Fetches a URL or accepts raw HTML and distills it into compressed Markdown, structured JSON, skeleton outline, or a BM25-focused budget excerpt — returning token savings proof alongside the result.","exampleAgentPrompt":"Distill the content at https://stripe.com/docs/api into clean Markdown using budget mode, focused on the query 'payment intents', and keep it under 1500 tokens — show me how many tokens you saved.","exampleUseCases":[{"title":"LLM context window budget management","prompt":"Fetch https://openai.com/research/gpt-4 and compress it into budget mode focused on the query 'context length improvements', capped at 800 tokens — I need to pass it to another model without blowing the context window."},{"title":"Structured data extraction from product page","prompt":"Take the raw HTML of this e-commerce page and distill it into structured mode so I get the product names, prices, and specs as clean JSON tables rather than a wall of HTML."},{"title":"Quick skeleton outline of documentation site","prompt":"Give me a skeleton outline of https://docs.github.com/en/actions so I can see the high-level structure of the page without reading the whole thing — just the headings and key sections."}],"resultDescription":"Returns a JSON object with a `data` field containing the distilled output (Markdown, structured JSON, skeleton, or BM25 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. Also includes optional cache status (HIT/MISS with latency) and billing details (fee charged, payment method, agent ID).","failureModes":["Missing or unreachable URL returns a fetch error with non-ok status","mode=budget without a query or max_tokens may return unfiltered or default output","Very large HTML payloads may hit processing limits or increase latency","Invalid URL format causes immediate validation rejection","If the page returns non-HTML content (e.g. PDF, binary), distillation may fail or return empty data","Cache MISS on first call may be slower than subsequent HIT calls"],"whenToPreferThis":"Choose this endpoint when you need to pass web content to an LLM but want to minimize token consumption — especially when working with long documentation pages, news articles, or HTML-heavy sites. It is uniquely suited for budget-constrained agent workflows where you need BM25 relevance filtering to extract only the most query-relevant content, or when you want structured JSON tables rather than raw HTML. Prefer over generic scrapers when token ROI reporting and compression metrics matter to your pipeline.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-23T06:32:15.125Z","isFirstParty":false,"canonicalSlug":"company-enrich-agentdiet-dev-web-page-html-token-optimizer-with-bm25-95033d8f"}