RAG Pipeline
Document upload, chunking, retrieval, and context injection.
The RAG pipeline handles document upload, chunking, vector indexing, retrieval, and context injection before model inference. Eridian manages the full lifecycle - your application sends a query; the orchestration layer retrieves relevant chunks and assembles context within token budgets automatically.
Document Upload
POST /v1/rag/documents
Authorization: Bearer eridian_sk_...
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | PDF, DOCX, or plain text |
project_id | string | Yes | Owning project |
collection_id | string | No | Logical grouping for retrieval |
chunking_strategy | string | No | fixed_size, semantic, or legal_clause |
metadata | object | No | Custom tags (matter_id, jurisdiction, etc.) |
Upload PDF, DOCX, or plain text documents. Documents are chunked, embedded, and stored in an encrypted vector store scoped to your project. Processing status is available via GET /v1/rag/documents/{id}.
Processing States
| Status | Meaning |
|---|---|
processing | Chunking and embedding in progress |
ready | Available for retrieval |
failed | Processing error; see error.message |
archived | Excluded from retrieval; retained for audit |
Chunking Strategies
| Strategy | Best For | Default params |
|---|---|---|
fixed_size | General-purpose documents | 512 tokens, 64 overlap |
semantic | Long-form content with natural section boundaries | Section-aware splits |
legal_clause | Contract libraries with clause-level retrieval | Clause boundary detection |
Legal workflows often pair legal_clause chunking with similarity_threshold: 0.78 because clause wording varies more than FAQ-style content.
Retrieval Configuration
{
"rag_config": {
"top_k": 5,
"similarity_threshold": 0.75,
"max_context_tokens": 4096,
"rerank": true,
"collection_ids": ["col_msa_templates"]
}
}
Enable RAG on inference requests with "features": ["rag"]. Responses include:
eridian.rag_injected- whether context was addederidian.rag_chunks- count of chunks injectederidian.rag_document_ids- source documents referenced
Context Injection
Retrieved chunks are injected into the prompt context before inference using a stable template:
<context>
[chunk 1 metadata + text]
[chunk 2 metadata + text]
</context>
<user_query>
...
The observability dashboard shows which chunks were used for each request, supporting audit and debugging in regulated workflows. Cache keys include document version hashes so corpus updates invalidate stale cached answers.
Delete and Reindex
DELETE /v1/rag/documents/{id}
POST /v1/rag/collections/{id}/reindex
Deletion is soft by default with 30-day retention for compliance holds. Reindex rebuilds embeddings after chunking strategy changes.
Error Codes
| HTTP | Code | Meaning |
|---|---|---|
| 413 | document_too_large | Exceeds tier upload limit |
| 422 | unsupported_format | File type not accepted |
| 404 | collection_not_found | Unknown collection ID |
See Inference for RAG feature flags and Semantic Caching for cache interaction with RAG prompts.
Production API credentials are issued with an institution workspace. Contact sales if you need access.