{"uid":"cap_falXIZdqwsEdL6ZWLClNq","slug":"prepare-context-scrub-compress-for-llm-calls-c6ab531c","name":"Prepare Context — Scrub & Compress for LLM Calls","description":"Agent-facing context scrubber: strip tool/browser noise, compress to a token budget, get a savings receipt. Free heuristic path — no API key.","url":"https://prepare.plaintools.vip/v1/prepare","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"raw":{"type":"string","description":"Raw tool/API/browser/history/docs text to scrub and compress"},"keep":{"type":"array","items":{"type":"string"},"description":"Optional JSON field names to keep when scrubbing structured payloads"},"mode":{"enum":["tool","history","docs"],"type":"string","description":"Scrub/compress strategy"},"schema":{"oneOf":[{"type":"object"},{"type":"array","items":{"type":"string"}}],"description":"Optional schema hint (object or string array) for structured keep/filter"},"target_model":{"type":"string","description":"Pricing key for estimated_usd_saved (e.g. generic, claude-sonnet, gpt-4o)"},"budget_tokens":{"type":"number","description":"Target token budget for the compressed packet"}}},"responseSchema":{"type":"json","example":{"mode":"tool","packet":"Clean status summary within budget…","tokens_in":8932,"loss_notes":["Dropped script/style blocks","Extractive compress to budget"],"tokens_out":800,"saved_ratio":0.9104,"estimated_usd_saved":0.016}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","displayCostAsset":"USDC","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.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_aIvGeVkNXSze-nwgVytSQ","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Strips tool/browser/API noise from raw text and compresses it to a target token budget, returning a cleaned packet plus a savings receipt showing tokens saved.","exampleAgentPrompt":"Before you call the next model, scrub and compress this raw tool output using 'tool' mode down to a 800-token budget targeting gpt-4o pricing — I want to see how many tokens and dollars we saved.","exampleUseCases":[{"title":"Compress browser noise before LLM call","prompt":"Take this raw browser page dump and scrub it in 'docs' mode, keeping only the fields 'title', 'body', and 'links', compressed to a 600-token budget for claude-sonnet — show me the savings ratio."},{"title":"Trim agent history to fit context window","prompt":"My agent history is blowing up my context window — run it through the scrubber in 'history' mode with a 1200-token budget and tell me how much I'm saving."},{"title":"Strip API response noise before chaining models","prompt":"This tool response has a ton of junk metadata I don't need — clean it up in 'tool' mode, keep only 'status' and 'result' fields, and compress it to 500 tokens so I can pass it to the next model call cheaply."}],"resultDescription":"Returns a JSON object with: 'packet' (the cleaned, compressed text ready for the next model call), 'tokens_in' (original token count), 'tokens_out' (compressed token count), 'saved_ratio' (fraction of tokens removed), 'loss_notes' (list of what was dropped), and 'estimated_usd_saved' (dollar savings estimate for the target model).","failureModes":["Empty or missing 'raw' field returns validation error","Invalid 'mode' enum value causes rejection","Budget_tokens set too low may result in severe lossy compression with extensive loss_notes","Unsupported target_model key may fall back to generic pricing estimate","Very short inputs may return minimal compression with near-zero saved_ratio"],"whenToPreferThis":"Choose this endpoint when an AI agent pipeline needs to reduce token bloat from tool outputs, browser scrapes, API responses, or conversation history before passing context to an expensive LLM. It is especially valuable when token costs matter, context windows are constrained, or structured JSON payloads need field-level filtering. It offers a no-API-key heuristic path at $0.01 per call with a quantified savings receipt, making it easy to justify the preprocessing cost against inference savings.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T18:30:22.908Z","isFirstParty":false}