{"uid":"cap_WRHdufNeWdsB5dPpL_muj","slug":"maha-context-compiler-c04920fa","name":"Maha Context Compiler","description":"Compress long documents and RAG inputs into token-budgeted, deduplicated context packs with source-linked provenance. Returns original and compiled token counts, so the saving is verifiable. Net-positive above N = fee / (r x p) tokens: r your reduction, p your input price. Extractive and budget-bound, so check includedPassages before relying on it. Ranks Latin, Cyrillic, Greek, Arabic and CJK; CJK coarser (bigrams). Not for tabular or heavily-structured payloads.","url":"https://www.mahastrategies.com/api/v1/compress","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object","required":["clientRequestId","task","tokenBudget","documents"],"properties":{"task":{"type":"string","maxLength":1200,"minLength":8},"scoring":{"enum":["bm25","keyword"],"type":"string"},"documents":{"type":"array","maxItems":8,"minItems":1},"budgetMode":{"enum":["guaranteed","estimated"],"type":"string"},"provenance":{"enum":["full","compact","none"],"type":"string"},"tokenBudget":{"type":"integer","maximum":16000,"minimum":64},"clientRequestId":{"type":"string","maxLength":120,"minLength":8}},"additionalProperties":false},"type":{"type":"string","const":"http"},"method":{"enum":["POST"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","required":["version","packId","clientRequestId","task","tokenBudget","context","metrics","includedPassages","sources","warnings","warningCodes","retentionBoundaries","inputHash","outputHash","sourceTextStored","compiledContextStored"],"properties":{"task":{"type":"string"},"packId":{"type":"string"},"context":{"type":"string"},"metrics":{"type":"object"},"sources":{"type":"array","maxItems":8,"minItems":1},"version":{"type":"string","const":"0.1.0"},"warnings":{"type":"array"},"inputHash":{"type":"string"},"outputHash":{"type":"string"},"tokenBudget":{"type":"integer","maximum":16000,"minimum":64},"warningCodes":{"type":"array"},"clientRequestId":{"type":"string","maxLength":120,"minLength":8},"includedPassages":{"type":"array"},"sourceTextStored":{"type":"boolean","const":false},"retentionBoundaries":{"type":"object"},"compiledContextStored":{"type":"boolean","const":false}},"additionalProperties":false}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","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.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_AlXgpy1njv-we_zzZ4SnV","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Ranks, deduplicates, and compresses a set of source documents into a token-budget-bounded context pack optimized for a specific task or question.","exampleAgentPrompt":"I have 6 research documents about climate policy and need to compress them into a context pack of at most 2000 tokens to answer the question 'What are the main barriers to carbon pricing adoption?' — use BM25 scoring, include full provenance, and use guaranteed budget mode.","exampleUseCases":[{"title":"RAG pipeline context window trimming","prompt":"I have 8 retrieved passages about EU AI regulation and need to compress them to fit within 1500 tokens to answer 'What compliance obligations apply to high-risk AI systems?' — rank them with BM25 and include full provenance so I can cite sources."},{"title":"Multi-document research summarization","prompt":"Take these 5 documents on semiconductor supply chain disruptions and compress them into a context pack of 1000 tokens that best supports answering 'Which countries are most exposed to chip shortages?' — use keyword scoring and compact provenance."},{"title":"Agent memory context pruning","prompt":"I have accumulated 7 conversation summaries and tool outputs during this session and need to compress them into a 500-token context pack focused on the task 'track open action items from today's meeting' — use BM25, guaranteed budget mode, and no provenance."}],"resultDescription":"A compiled context pack containing the most task-relevant excerpts from the submitted documents, deduplicated and trimmed to fit within the specified token budget. The response includes ranked content, a model-neutral token estimate, and optional provenance metadata (full, compact, or none) mapping excerpts back to their source document IDs and titles.","failureModes":["Documents array empty or exceeds 8 items — validation error returned","Token budget below 64 or above 16000 — schema validation rejection","Task string too short (under 8 chars) or too long (over 1200 chars) — request rejected","Invalid scoring enum value — bad request error","clientRequestId too short or missing required length — rejected","Individual document text empty — validation failure","Service unavailable or payment failure via x402 — 402 or 503 response"],"whenToPreferThis":"Choose this endpoint when you need to fit a variable number of retrieved or accumulated documents into a strict token budget for downstream LLM calls, particularly in RAG pipelines, agentic memory systems, or multi-document QA workflows. It is preferable over manual truncation because it ranks and deduplicates by task relevance using BM25 or keyword scoring, rather than simply cutting off text. Use it when you need traceable provenance of which source contributed which content, or when you need a guaranteed (hard cap) vs estimated token budget mode.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T00:32:36.158Z","isFirstParty":false}