Skip to content

RAG API

All RAG endpoints are under /v1/{app_id}/rag/. Authentication: Authorization: Bearer {service_key_or_jwt}.

See RAG (Native) for conceptual overview and SDK examples.

POST /v1/{app_id}/rag/collections

Request body:

FieldTypeRequiredDescription
namestringYesLowercase alphanumeric, hyphens, underscores
descriptionstringNoHuman-readable description
accessModeprivate | shared | customNoDefault: private
chunkSizenumberNoCharacters per chunk. Default: 512
chunkOverlapnumberNoOverlap between chunks. Default: 64

Response: Collection object (201).


GET /v1/{app_id}/rag/collections

Response: Array of Collection objects.


GET /v1/{app_id}/rag/collections/{name}

Returns collection details including document and chunk counts.

Response: CollectionDetails object.


DELETE /v1/{app_id}/rag/collections/{name}

Permanently deletes the collection and all its documents, chunks, and embeddings. Irreversible.

Response: 204 No Content.


POST /v1/{app_id}/rag/collections/{name}/ingest

Enqueues a document for async processing. Returns immediately with status: "pending".

Request body (text):

FieldTypeRequiredDescription
textstringYes*Raw text content to ingest
filenamestringNoDisplay name for the document
metadataobjectNoArbitrary key-value metadata stored with each chunk

Request body (file from storage):

FieldTypeRequiredDescription
storage_object_idstringYes*Object ID returned by the storage upload endpoint
filenamestringNoOverride display name
metadataobjectNoArbitrary key-value metadata

*Either text or storage_object_id is required.

Response: IngestResult object (202).

{
"documentId": "uuid",
"status": "pending",
"message": "Document queued for processing"
}

GET /v1/{app_id}/rag/collections/{name}/documents

Response: Array of RagDocument objects.


GET /v1/{app_id}/rag/collections/{name}/documents/{document_id}

Returns document status and metadata. Use this to poll until status is ready or failed.

Response: RagDocument object.


DELETE /v1/{app_id}/rag/collections/{name}/documents/{document_id}

Deletes the document and all its vector chunks. Irreversible.

Response: 204 No Content.


POST /v1/{app_id}/rag/collections/{name}/query

Request body:

FieldTypeRequiredDescription
querystringYesNatural language question
topKnumberNoNumber of chunks to return. Default: 5
thresholdnumberNoMinimum cosine similarity (0–1). Chunks below excluded.
synthesizebooleanNoGenerate an AI answer from retrieved chunks. Default: false
modelstringNoModel for synthesis (e.g. anthropic/claude-haiku-4-5). Auto-selected if omitted.
filterobjectNoMetadata filter (key-value pairs). Only chunks with matching metadata are returned.

Response: QueryResult (when synthesize: false) or SynthesizedQueryResult (when synthesize: true).


{
"id": "uuid",
"name": "support-docs",
"description": "Product support documentation",
"accessMode": "shared",
"chunkSize": 512,
"chunkOverlap": 64,
"createdAt": "2026-04-23T10:00:00Z",
"updatedAt": "2026-04-23T10:00:00Z"
}

Extends Collection with:

{
"documentCount": 12,
"chunkCount": 347
}
{
"id": "uuid",
"collectionId": "uuid",
"filename": "refund-policy.pdf",
"status": "ready",
"chunkCount": 28,
"metadata": {},
"errorMessage": null,
"createdAt": "2026-04-23T10:00:00Z",
"updatedAt": "2026-04-23T10:01:30Z"
}

Status values: pendingprocessingready | failed

{
"documentId": "uuid",
"status": "pending",
"message": "Document queued for processing"
}
{
"chunks": [
{
"text": "Refunds are accepted within 30 days...",
"score": 0.92,
"documentId": "uuid",
"metadata": {}
}
]
}

Extends QueryResult with:

{
"chunks": [...],
"answer": "Refunds are accepted within 30 days of purchase with a valid receipt.",
"model": "anthropic/claude-haiku-4-5"
}