AI Context Distiller: Cut Tokens from HTML, JSON & Logs avatar

AI Context Distiller: Cut Tokens from HTML, JSON & Logs

Pricing

from $2.50 / 1,000 distill payloads

Go to Apify Store
AI Context Distiller: Cut Tokens from HTML, JSON & Logs

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

Chris Day

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

2 days ago

Last modified

Features

Limited permissionsSingle-tenantServer interface

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-distiller to your MCP client; the tool is geeky_goth_gamer--ai-context-distiller. Or use call-actor with "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/distill with Authorization: Bearer YOUR_TOKEN and the input JSON. Follow up with POST /slice and { "cacheId": "...", "sectionIds": ["s2", "s5"] } while the process is warm. GET /health is a liveness check.
  • Python: ApifyClient(token).actor("geeky_goth_gamer/ai-context-distiller").call(run_input=...), then read client.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_TOKEN with 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.

FieldDefaultNotes
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.
contentTypeautohtml, 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.
maxTokens4000Cap 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, …).
compressionnonenone, light, or telegraphic.
includeOutlinetrueSection ids, headings and token counts.
maxFileSizeMb5URL download cap. Oversize fetches are not billed.
timeoutSeconds30URL timeout.

Output

One dataset item (same shape as the Standby JSON body):

  • distilledText: the pruned, optionally ranked and compressed text
  • distilledJson: the pruned JSON object, when the source is JSON and was not sliced or compressed into prose
  • outline[]: id, heading, tokenCount, score
  • originalTokens, distilledTokens, tokensSaved, reductionPct
  • tokenizer: tiktoken:cl100k_base
  • guardsPreserved: { ok, checked, missing, categories } — whether protected facts in the selected text survived compression
  • cacheId: present in Standby mode so /slice can pull sections without resending the payload (the cache lives only while that process is warm)
  • billed, eventCharged (distill-payload or distill-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 — liveness
  • POST /distill — same input as a normal run, JSON response
  • POST /slice — { "cacheId": "...", "sectionIds": ["s2"] } or the content again plus sectionIds
  • Any request carrying the x-apify-container-server-readiness-probe header is answered immediately with HTTP 200 and body ok, including probes to /

Standard input-interface runs (Console, call-actor, run-sync) still work: one input, one dataset item, then the run exits.

Pricing

EventPriceWhen it is charged
distill-payload (primary)US$0.0025One successful inline distill (text, html, json or logs). Also charged for a successful /slice.
distill-urlUS$0.005One successful URL fetch + distill.
apify-actor-startUS$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.ok in your loop.
  • Standby cacheId values are per-process and disappear when the run idles out. Resubmit the payload (or store the outline yourself) if the cache is gone.