Skip to main content

API Reference

RAG API - Bijak Cloud Docs

Upload documents, manage corpora, and run grounded queries with citations using RAG Studio.

Overview

RAG Studio lets you ground completions in your own documents. Upload files into a corpus, wait for indexing, then query the corpus and receive answers with citations to the source chunks.

Create a corpus

curl -X POST https://api.bijakcloud.example/v1/rag/corpora \
  -H "Authorization: Bearer $BIJAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "hr-handbook",
    "chunking": "semantic",
    "embedding_model": "bijak-embed-1024"
  }'

The response includes the corpus ID. Chunking strategies are semantic, fixed, and paragraph. The default is semantic, which adapts chunk boundaries to document structure.

Upload documents

curl -X POST https://api.bijakcloud.example/v1/rag/corpora/$CORPUS_ID/documents \
  -H "Authorization: Bearer $BIJAK_API_KEY" \
  -F "file=@./handbook.pdf" \
  -F "metadata={\"department\":\"hr\",\"year\":2026}"

Documents may be uploaded in batches up to 100 files per request. Supported formats include PDF, DOCX, TXT, MD, and HTML.

Query the corpus

curl -X POST https://api.bijakcloud.example/v1/rag/corpora/$CORPUS_ID/query \
  -H "Authorization: Bearer $BIJAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "How many days of annual leave do employees get?",
    "top_k": 5,
    "include_citations": true
  }'

The response includes the model’s answer plus a citations array. Each citation has the source document ID, the chunk text, and a relevance score. Citations are always returned, never optional, so every grounded answer is auditable.

Streaming queries

For long answers, stream the response:

curl -X POST https://api.bijakcloud.example/v1/rag/corpora/$CORPUS_ID/query \
  -H "Authorization: Bearer $BIJAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"Summarise the grievance policy.","stream":true}'

Streamed responses follow the same server-sent-event format as the inference API, with a final event containing the full citation list.

Corpus management

List, inspect, and delete corpora:

# List all corpora
curl https://api.bijakcloud.example/v1/rag/corpora -H "Authorization: Bearer $BIJAK_API_KEY"

# Get corpus status
curl https://api.bijakcloud.example/v1/rag/corpora/$CORPUS_ID -H "Authorization: Bearer $BIJAK_API_KEY"

# Delete a corpus (cascades to all documents and embeddings)
curl -X DELETE https://api.bijakcloud.example/v1/rag/corpora/$CORPUS_ID -H "Authorization: Bearer $BIJAK_API_KEY"

Deletion is irreversible and produces an audit log entry. Embeddings are wiped from primary storage and tombstoned in cold storage until the retention window expires.

Audit and compliance

Every document upload, query, and deletion produces an audit log entry. Embeddings are encrypted with HSM-managed keys. Retention windows are configurable per corpus.

Next steps

  • Read the Inference API reference for the underlying chat model.
  • Review Auth for service-account patterns suited to batch upload jobs.
  • See Concepts: Sovereignty for the data-residency posture.