# Maha Context Compiler

> Maha Context Compiler is a paid API for AI agents from www.mahastrategies.com, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Ranks, deduplicates, and compresses a set of source documents into a token-budget-bounded context pack optimized for a specific task or question.

## Facts

- Endpoint: POST https://www.mahastrategies.com/api/v1/compress
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/maha-context-compiler-c04920fa
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_WRHdufNeWdsB5dPpL_muj

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 maha-context-compiler-c04920fa -d '<json body>'
```

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

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "type": "object",
 "properties": {
  "input": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "type": "string",
     "enum": [
      "POST"
     ]
    },
    "bodyType": {
     "type": "string",
     "enum": [
      "json",
      "form-data",
      "text"
     ]
    },
    "body": {
     "type": "object",
     "additionalProperties": false,
     "properties": {
      "clientRequestId": {
       "type": "string",
       "minLength": 8,
       "maxLength": 120
      },
      "task": {
       "type": "string",
       "minLength": 8,
       "maxLength": 1200
      },
      "tokenBudget": {
       "type": "integer",
       "minimum": 64,
       "maximum": 16000
      },
      "documents": {
       "type": "array",
       "minItems": 1,
       "maxItems": 8
      },
      "provenance": {
       "type": "string",
       "enum": [
        "full",
        "compact",
        "none"
       ]
      },
      "scoring": {
       "type": "string",
       "enum": [
        "bm25",
        "keyword"
       ]
      },
      "budgetMode": {
       "type": "string",
       "enum": [
        "guaranteed",
        "estimated"
       ]
      }
     },
     "required": [
      "clientRequestId",
      "task",
      "tokenBudget",
      "documents"
     ]
    }
   },
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "additionalProperties": false,
     "properties": {
      "version": {
       "type": "string",
       "const": "0.1.0"
      },
      "packId": {
       "type": "string"
      },
      "clientRequestId": {
       "type": "string",
       "minLength": 8,
       "maxLength": 120
      },
      "task": {
       "type": "string"
      },
      "tokenBudget": {
       "type": "integer",
       "minimum": 64,
       "maximum": 16000
      },
      "context": {
       "type": "string"
      },
      "metrics": {
       "type": "object"
      },
      "includedPassages": {
       "type": "array"
      },
      "sources": {
       "type": "array",
       "minItems": 1,
       "maxItems": 8
      },
      "warnings": {
       "type": "array"
      },
      "warningCodes": {
       "type": "array"
      },
      "retentionBoundaries": {
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/maha-context-compiler-c04920fa/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from www.mahastrategies.com](https://www.zero.xyz/host/www.mahastrategies.com/llms.txt)
