{"uid":"cap_xgs_7IKW4MkkRAS9RPELv","slug":"context-preparation-api-pack-endpoint-f39ecc81","name":"Context Preparation API – Pack Endpoint","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/pack","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.002","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_CF4S9sKtFjMojAVDdi3Kk","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","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 documents into a ready-to-use context window for a target AI model.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"RAG context window for customer support bot","prompt":"I have 8 support articles and the user asked 'How do I reset my 2FA?'—clean and chunk each article at 400 tokens, rank them by relevance to that question, and pack the top results into a 2048-token context I can send straight to Claude."},{"title":"Safety-screening legal docs before LLM review","prompt":"Before I send these three contract drafts to the model, run a safety inspection on all of them, flag any contradictions between the documents, and redact any personal information—then give me back a clean packed context up to 8192 tokens."},{"title":"Grounded Q&A context for a research assistant","prompt":"I've got a pile of academic paper excerpts and the question is 'What evidence links sleep deprivation to cognitive decline?'—chunk them at 600 tokens, hybrid-rank using semantic relevance, check for contradictions, and pack the result into a 6000-token window targeting GPT-4-turbo."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-16T00:32:56.216Z","isFirstParty":false}