# Context Preparation API

> Context Preparation API is a paid API for AI agents from nexus-x402-ff2a.onrender.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-14).

Cleans, inspects, chunks, ranks, and token-packs multi-format text documents into AI-agent-ready context with safety checks and contradiction detection.

## Facts

- Endpoint: POST https://nexus-x402-ff2a.onrender.com/v1/prepare
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/context-preparation-api-4ea6661a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_SwFF2spVEcmjgKTvzgpWU

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 context-preparation-api-4ea6661a -d '<json body>'
```

Example prompt: Take these three documents about our product roadmap, clean and chunk them into 512-token pieces, check them for safety issues and contradictions, then pack everything into a 4096-token context window optimized for GPT-4 — and make sure PII is redacted.

## When to prefer this

Choose this endpoint when you need a single deterministic pipeline that combines cleaning, safety checking, chunking, relevance ranking, and token-budget-aware packing in one call — rather than stitching together separate tools for each step. It is especially well-suited for RAG pre-processing, agent context assembly, and any workflow where content must be sanitized and contradiction-checked before reaching a language model. Prefer it over generic text splitters when you need safety inspection or hybrid ranking included, and over full LLM calls when you want deterministic, reproducible context preparation without generation.

## Known failure modes

- Missing required content or documents field returns a validation error
- maxTokens set too low to fit even a single chunk may return empty or truncated content
- Invalid queryEmbedding dimensions cause ranking to fail silently or return unranked chunks
- Extremely large documents exceeding service limits may time out
- Malformed target model object may cause packing to fall back to defaults
- Payment failure or insufficient USDC balance returns a 402 response before processing begins

## How this service works

Deterministic multi-format cleaning, safety inspection, structural chunking, hybrid ranking, contradiction checks, and target-model token packing for AI agents.

## Output

Returns a JSON object containing the operation type performed, the cleaned and packed content string, an array of structural chunks (each as an object), a safety array with any flagged issues, a warnings array, a metrics object with token counts and processing stats, the target model config, and optionally a potentialContradictions array listing detected conflicts across the input documents.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "redact": {
   "type": "boolean",
   "description": "Defaults to true for /prepare and false for other operations."
  },
  "target": {
   "type": "object"
  },
  "content": {
   "type": "string"
  },
  "question": {
   "type": "string"
  },
  "documents": {
   "type": "array"
  },
  "maxTokens": {
   "type": "integer"
  },
  "chunkTokens": {
   "type": "integer"
  },
  "queryEmbedding": {
   "type": "array"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "operation",
  "content",
  "chunks",
  "warnings",
  "safety",
  "metrics",
  "target"
 ],
 "properties": {
  "chunks": {
   "type": "array",
   "items": {
    "type": "object"
   }
  },
  "safety": {
   "type": "array",
   "items": {
    "type": "object"
   }
  },
  "target": {
   "type": "object"
  },
  "content": {
   "type": "string"
  },
  "metrics": {
   "type": "object"
  },
  "warnings": {
   "type": "array",
   "items": {
    "type": "object"
   }
  },
  "operation": {
   "enum": [
    "clean",
    "inspect",
    "pack",
    "prepare"
   ]
  },
  "potentialContradictions": {
   "type": "array",
   "items": {
    "type": "object"
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/context-preparation-api-4ea6661a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from nexus-x402-ff2a.onrender.com](https://www.zero.xyz/host/nexus-x402-ff2a.onrender.com/llms.txt)
