# Context Preparation API – Pack Endpoint

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

Cleans, inspects, chunks, ranks, and token-packs multi-format documents into a ready-to-use context window for a target AI model.

## Facts

- Endpoint: POST https://nexus-x402-ff2a.onrender.com/v1/pack
- Price: $0.002/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-pack-endpoint-f39ecc81
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_xgs_7IKW4MkkRAS9RPELv

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-pack-endpoint-f39ecc81 -d '<json body>'
```

Example prompt: Take these 5 research documents, clean and chunk them at 512 tokens per chunk, rank them against the question 'What are the latest findings on mRNA vaccines?', redact any PII, and pack everything into a 4096-token context window ready for GPT-4.

## When to prefer this

Choose this endpoint when you need a deterministic, reproducible pipeline that handles the full pre-LLM document workflow in one call: cleaning noise, inspecting for safety issues, chunking, relevance ranking, contradiction detection, and token-budget-aware packing. It is especially valuable in RAG pipelines where you need hybrid ranking against a query embedding and must respect a strict token limit for a specific target model. Prefer it over ad-hoc chunking scripts when safety inspection and PII redaction are required in the same pipeline.

## Known failure modes

- Content too large to fit any chunks within maxTokens — returns empty chunks with a warning
- Malformed queryEmbedding array causes ranking to fail — returns unranked chunks with a warning
- Unsupported document format in the documents array — returns a warning and skips that document
- Missing required content or documents field — returns a 400-level error
- Model target specification not recognized — metrics and token packing may fall back to defaults

## 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 final packed context string, an array of ranked document chunks with metadata, a safety array listing any flagged content, an array of warnings, a potentialContradictions array highlighting conflicting claims across documents, an operation field indicating which pipeline ran (clean/inspect/pack/prepare), and a metrics object with token counts and processing stats.

## 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-pack-endpoint-f39ecc81/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)
