AI Context Distiller: Cut Tokens from HTML, JSON & Logs
Pricing
from $2.50 / 1,000 distill payloads
AI Context Distiller: Cut Tokens from HTML, JSON & Logs
Prune HTML, JSON, logs or prose and return query-focused, token-budgeted text for AI agents, with a safe telegraphic compression mode that never drops negations, numbers or code. Standby HTTP for sub-second warm calls. $0.0025 per payload or $0.005 per URL.
Pricing
from $2.50 / 1,000 distill payloads
Rating
0.0
(0)
Developer
Chris Day
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
2 days ago
Last modified
Categories
Features
Share
AI Context Distiller for AI Agents
Send this Actor a web URL, raw HTML, a JSON API payload, server logs, or long prose / Markdown / CSV. It prunes boilerplate, ranks the remainder against an optional question, and returns compact text that fits a token budget — plus a section outline so the agent can pull only the slices it still needs.
It does not call a language model. Distillation is deterministic (HTML cleanup, JSON pruning, log collapsing, BM25 ranking, and an optional safe telegraphic compression mode). Token counts use OpenAI tiktoken cl100k_base.
When an AI agent should use this
Use geeky_goth_gamer/ai-context-distiller when:
- A web page, API response, log dump or document is too large to paste into the model, and you want a much smaller, query-focused extract.
- You want to cut LLM input tokens before the model sees the payload (the call is priced so typical token savings exceed the fee).
- You need a warm, low-latency endpoint (
POST /distill,POST /slice,GET /health) in Apify Standby / Server mode, with an outline you can slice on follow-up calls.
Don't use it for:
- Fetching a citation-checked evidence pack (use a dedicated evidence-pack Actor).
- Rendering JavaScript-only pages to a screenshot or PDF.
- Tasks that need a language model to paraphrase or summarise — this tool only prunes, ranks and optionally compresses; it does not rewrite facts.
Example input:
{"url": "https://example.com/","query": "What is this domain used for?","maxTokens": 800,"compression": "light"}
Output: One dataset item (or a JSON HTTP body in Standby mode): distilledText, outline (section ids, headings, token counts), originalTokens, distilledTokens, tokensSaved, reductionPct, tokenizer, guardsPreserved, and optional distilledJson.
Cost: $0.0025 per inline payload (text / html / json / logs) or $0.005 per URL fetch + distill. Failed fetches and invalid input are not billed. Apify also charges the standard $0.00005 Actor-start fee on ordinary runs.
Call it from an agent:
- Apify MCP server: add
https://mcp.apify.com/?tools=geeky_goth_gamer/ai-context-distillerto your MCP client; the tool isgeeky_goth_gamer--ai-context-distiller. Or usecall-actorwith"actor": "geeky_goth_gamer/ai-context-distiller". - Standby HTTP (once the Server interface is enabled):
POST https://geeky-goth-gamer--ai-context-distiller.apify.actor/distillwithAuthorization: Bearer YOUR_TOKENand the input JSON. Follow up withPOST /sliceand{ "cacheId": "...", "sectionIds": ["s2", "s5"] }while the process is warm.GET /healthis a liveness check. - Python:
ApifyClient(token).actor("geeky_goth_gamer/ai-context-distiller").call(run_input=...), then readclient.dataset(run["defaultDatasetId"]).list_items().items. - HTTP run:
POST https://api.apify.com/v2/acts/geeky_goth_gamer~ai-context-distiller/run-sync-get-dataset-items?token=YOUR_TOKENwith the input JSON as the body.
Why this exists
Language-model calls are billed by tokens. Agents routinely paste whole pages, bloated JSON and repetitive logs into the context window, paying for scripts, navigation, null fields and repeated lines. This Actor is meant to sit in front of the model: one cheap tool call returns the high-signal remainder, a token-saving report, and an index of sections the agent can retrieve later.
A second, optional telegraphic mode drops predictable English filler (articles, copulas, verbose transitions) so the receiving model reconstructs the grammar by prediction. It keeps real English words — it does not invent a shorthand language — and it will not drop or alter negations, logical qualifiers, numbers, dates, URLs, emails, identifiers, headings, quotations, Markdown tables or code.
Input
Pass exactly one of url, text, html or json.
| Field | Default | Notes |
|---|---|---|
url | (optional) | One public http(s) page. Private, loopback and metadata addresses are rejected. |
text / html / json | (optional) | Inline payload, max 2,000,000 characters. json may be an object or a JSON string. |
contentType | auto | html, json, logs, markdown, csv, text, or auto. |
query | (empty) | Rank sections against this question. Phrases in "double quotes" get a bonus. |
focusTerms | (empty) | Extra terms to boost. |
maxTokens | 4000 | Cap on distilledText in cl100k_base tokens. 0 means no cap. |
keepFields | (empty) | JSON dot-paths to keep, e.g. items.*.price. |
sectionIds | (empty) | Return only these outline ids (s1, s2, …). |
compression | none | none, light, or telegraphic. |
includeOutline | true | Section ids, headings and token counts. |
maxFileSizeMb | 5 | URL download cap. Oversize fetches are not billed. |
timeoutSeconds | 30 | URL timeout. |
Output
One dataset item (same shape as the Standby JSON body):
distilledText: the pruned, optionally ranked and compressed textdistilledJson: the pruned JSON object, when the source is JSON and was not sliced or compressed into proseoutline[]:id,heading,tokenCount,scoreoriginalTokens,distilledTokens,tokensSaved,reductionPcttokenizer:tiktoken:cl100k_baseguardsPreserved:{ ok, checked, missing, categories }— whether protected facts in the selected text survived compressioncacheId: present in Standby mode so/slicecan pull sections without resending the payload (the cache lives only while that process is warm)billed,eventCharged(distill-payloadordistill-url)
Standby / Server mode
When the Actor is started through Apify's server interface (APIFY_META_ORIGIN=STANDBY), it listens on ACTOR_WEB_SERVER_PORT and handles:
GET /health— livenessPOST /distill— same input as a normal run, JSON responsePOST /slice—{ "cacheId": "...", "sectionIds": ["s2"] }or the content again plussectionIds- Any request carrying the
x-apify-container-server-readiness-probeheader is answered immediately with HTTP 200 and bodyok, including probes to/
Standard input-interface runs (Console, call-actor, run-sync) still work: one input, one dataset item, then the run exits.
Pricing
| Event | Price | When it is charged |
|---|---|---|
distill-payload (primary) | US$0.0025 | One successful inline distill (text, html, json or logs). Also charged for a successful /slice. |
distill-url | US$0.005 | One successful URL fetch + distill. |
apify-actor-start | US$0.00005 (Apify default) | Once when a standard run starts. Covers the first 5 seconds of compute. |
Failed fetches, rejected URLs and invalid input are free. Your maximum cost per run is respected: if it is below the event price, nothing is processed.
A typical page is tens of thousands of tokens; dropping even a few thousand cl100k_base input tokens usually saves more than US$0.001–0.002 at current model prices.
Safety
URL fetches are SSRF-safe: only http/https on standard ports, every redirect hop is re-validated, and private, loopback, link-local, CGNAT and cloud-metadata addresses are blocked. Downloads are size- and time-capped. The helper connects to already-checked IPs, IPv4 first (Apify containers often have no IPv6 route).
Limitations
- JavaScript-rendered pages will have little or no text; render them first if you need the visible DOM.
- Telegraphic mode is for model input, not for publishing. It is tested to preserve protected facts, but you should still keep
guardsPreserved.okin your loop. - Standby
cacheIdvalues are per-process and disappear when the run idles out. Resubmit the payload (or store the outline yourself) if the cache is gone.