# agent402.tools RAG Corpus Prep

> agent402.tools RAG Corpus Prep is a paid API for AI agents from agent402.tools, paid per call via x402, $0.05/call, status unknown (last checked 2026-09-14).

Takes a raw document and produces a vector-DB-ready JSONL dataset by measuring, token-counting (OpenAI BPE), and chunking the text at correct token boundaries.

## Facts

- Endpoint: POST https://agent402.tools/api/skill/rag-prep
- Price: $0.05/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-rag-corpus-prep-c85c4a18
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_91ZDk-DOF6o3cZJyYrzX_

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 agent402-tools-rag-corpus-prep-c85c4a18 -d '<json body>'
```

Example prompt: Take this raw text and prep it for my vector database — tokenize it with OpenAI BPE, chunk it at proper token boundaries, and return a JSONL dataset I can feed straight into my embedding pipeline: [raw document text here].

## When to prefer this

Choose this endpoint when you need a deterministic, reproducible chunking pipeline that uses real OpenAI BPE tokenization and produces clean JSONL output ready for vector DB ingestion — especially when consistency and token-boundary accuracy matter more than speed or custom chunking logic.

## Known failure modes

- Empty or missing 'doc' field returns a 400 validation error
- Document too large may exceed processing limits
- Malformed input (non-string doc) returns schema validation error
- Network timeout on very large documents
- Payment failure (x402) results in 402 Payment Required before processing begins

## How this service works

Bundled execution of the RAG corpus prep workflow - Take a raw document and turn it into a vector-DB-ready JSONL dataset, deterministically. Measures the corpus, token-counts it with the real OpenAI BPE, chunks at the right token boundary, attache...

## Output

A vector-DB-ready JSONL dataset where each record represents a properly token-bounded chunk of the source document, annotated with token counts and ready for embedding ingestion.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "doc": {
   "type": "string",
   "description": "the source document to prep for embedding (raw text, no markup required)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "args": {
   "doc": "Alice from acme@example.com filed a support ticket on 2026-06-21 about the checkout flow returning a 502 from api.acme.com/v2/orders. Engineer Bob investigated and found the issue was a connection-pool exhaustion in the order-service: postgres max_connections was 100 and the pool had been silently leaking since the rollout of feature flag #orders-2026. Fix landed in commit 9a3b2c1; deploy went out 2026-06-22. Follow-up: add pgbouncer in front of the order-service and an alert on pool.in_use / max_connections > 0.8 in PagerDuty. Slack thread: #incident-orders-502. Mentioned engineers: @alice @bob @carol."
  },
  "pack": "rag-prep",
  "steps": [
   {
    "ok": true,
    "slug": "text-stats",
    "result": {}
   },
   {
    "ok": true,
    "slug": "token-count",
    "result": {}
   },
   {
    "ok": true,
    "slug": "text-chunk",
    "result": {}
   },
   {
    "ok": true,
    "slug": "extract-entities",
    "result": {}
   },
   {
    "ok": true,
    "slug": "keywords",
    "result": {}
   },
   {
    "ok": true,
    "slug": "jsonl",
    "result": {}
   },
   {
    "ok": true,
    "slug": "json-validate",
    "result": {}
   }
  ],
  "summary": "7/7 steps succeeded"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-rag-corpus-prep-c85c4a18/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
