Guide: Compile API
Compile verified organizational context into structured, injection-resistant prompts with role-based ACL pre-filtering using POST /v1/compile.
Endpoint Overview
POST /v1/compile transforms a loose user request into an enriched, production-ready LLM prompt with grounded internal business context.
It queries integrated corporate sources (CRM, ticketing, ERP), runs role-based access control (RBAC) pre-filtering to ensure users only receive data they are permitted to view, and wraps context in randomized tamper-proof delimiters to prevent indirect prompt injection.
Output fits precisely within a caller-specified tokenBudget to avoid overflowing LLM context windows.
Request Parameters
The compile endpoint accepts the following fields:
- prompt (string, required): The raw user prompt, e.g. "Prepare summary for Acme Corp".
- intent (string, default: "deal_summary"): Context resolution template key.
- entityName (string, optional): Resolved target entity (e.g. "Acme Corp").
- tokenBudget (integer, default: 600): Maximum allowable token count for injected context chunks.
- stream (boolean, default: false): Enables Server-Sent Events (SSE) streaming for T2 refinement.
Code Examples (curl, TypeScript, Python)
The examples below demonstrate compiling internal CRM context for an account review:
curl -s -X POST http://localhost:3000/v1/compile \
-H "Content-Type: application/json" \
-H "Authorization: Bearer test-token" \
-d '{
"prompt": "Summarize account status for Acme Corp",
"intent": "deal_summary",
"tokenBudget": 600
}'Structured Context & Provenance
The response structure provides end-to-end auditability and clear provenance for every injected chunk:
- compiledPrompt: The finalized prompt with XML context containers and instructions.
- variables: Extracted and normalized entity attributes.
- survivingChunksCount: Number of context fragments that passed RBAC filters.
- neutralizedThreatsCount: Count of indirect injections or adversarial tags stripped.
- provenanceList: Array detailing original source system, document ID, and last-modified timestamp.