# Context Preparation API – /v1/clean

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

Cleans, safety-inspects, structurally chunks, hybrid-ranks, contradiction-checks, and token-packs text or documents for consumption by a target AI model.

## Facts

- Endpoint: POST https://nexus-x402-ff2a.onrender.com/v1/clean
- Price: $0.0005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/context-preparation-api-v1-clean-d4b1d45e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_jJQQSgs1iEw9rh6StfXrd

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-v1-clean-d4b1d45e -d '<json body>'
```

Example prompt: Clean and safety-inspect this 3,000-word document, chunk it into 256-token segments, rank the chunks against my question 'What are the key risks?', and pack the top results into a 2,048-token budget for GPT-4o — also flag any contradictions and redact PII.

## When to prefer this

Choose this endpoint when you need a deterministic, multi-step preprocessing pipeline — cleaning, safety inspection, chunking, ranking, contradiction detection, and token packing — in a single call, rather than stitching together separate utilities. Ideal for RAG pipelines, multi-document QA agents, or any workflow where raw text must be safely and precisely prepared before being handed to a downstream LLM within a strict token budget.

## Known failure modes

- Missing required 'content' or 'documents' field returns a validation error
- Token budget (maxTokens) too small to fit even a single chunk may return empty chunks array
- Invalid or unsupported target model spec may cause target metadata to be null or empty
- Malformed query embedding array causes ranking step to fail or be skipped
- Very large documents exceeding service limits may result in truncation or a 413 error
- Network timeout on render.com cold-start instances may cause initial latency spikes

## 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 with the operation type ('clean', 'inspect', 'pack', or 'prepare'), the cleaned/transformed content string, an array of structured chunks, a safety array with flagged issues, a warnings array, a metrics object (token counts, ranking scores), target model metadata, and an optional potentialContradictions array listing conflicting passages across 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-v1-clean-d4b1d45e/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)
