{"uid":"cap_SwFF2spVEcmjgKTvzgpWU","slug":"context-preparation-api-4ea6661a","name":"Context Preparation API","description":"Deterministic multi-format cleaning, safety inspection, structural chunking, hybrid ranking, contradiction checks, and target-model token packing for AI agents.","url":"https://nexus-x402-ff2a.onrender.com/v1/prepare","method":"POST","headers":{},"bodySchema":{"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"}}},"responseSchema":{"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"}}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_wPLQkSW6Lt2-64fW9HLeh","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Cleans, inspects, chunks, ranks, and token-packs multi-format text documents into AI-agent-ready context with safety checks and contradiction detection.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"RAG pipeline document pre-processing","prompt":"I have 10 support articles I want to feed into my RAG system — can you clean them, split them into 400-token chunks, rank the most relevant ones to the question 'how do I reset my password?', and pack them into a 2000-token context?"},{"title":"Safety inspection before agent handoff","prompt":"Before passing this user-submitted document to my AI agent, run it through safety inspection and PII redaction so I can see any warnings or flagged content — max 1500 tokens please."},{"title":"Contradiction detection across research notes","prompt":"I've got a set of research notes that might conflict with each other — can you chunk them, check for contradictions, and give me a cleaned, packed version under 3000 tokens ready for Claude?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T00:36:15.205Z","isFirstParty":false}