# Prepare Context — Scrub & Compress for LLM Calls

> Prepare Context — Scrub & Compress for LLM Calls is a paid API for AI agents from prepare.plaintools.vip, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-15).

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.

## Facts

- Endpoint: POST https://prepare.plaintools.vip/v1/prepare
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/prepare-context-scrub-compress-for-llm-calls-c6ab531c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_falXIZdqwsEdL6ZWLClNq

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 prepare-context-scrub-compress-for-llm-calls-c6ab531c -d '<json body>'
```

Example prompt: 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.

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

Agent-facing context scrubber: strip tool/browser noise, compress to a token budget, get a savings receipt. Free heuristic path — no API key.

## Output

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).

## Request schema (JSON Schema)

```json
{
 "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"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/prepare-context-scrub-compress-for-llm-calls-c6ab531c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from prepare.plaintools.vip](https://www.zero.xyz/host/prepare.plaintools.vip/llms.txt)
