BETA

alRetrieval

Ingest documents and query them with natural-language semantic retrieval. Supports PDF, DOCX, PPTX, TXT, and Markdown files.

Path
/v1/alRetrieval
Key scope
alretrieval

Supported file formats

PDF, DOCX, PPTX, TXT, MD

PDFs are processed via OCR; DOCX, PPTX, TXT, and MD have text extracted directly — no OCR cost

Scope Required: All alRetrieval endpoints require an API key with the alretrieval scope. Pass it as a Bearer token in the Authorization header.

How it works

Every request works inside a collection that belongs to your account: create a collection, upload documents, wait until they are ready, then retrieve passages or generate an answer that cites them. Lists are paged with limit, offset, total and has_more. Every response carries an X-Request-Id header; quote it when you contact support.

Code Examples:

retrieval_quickstart.py
import time, requests

BASE = "https://alapi.deep.sa/v1/alRetrieval"
headers = {"Authorization": "Bearer YOUR_API_KEY"}

# 1. Create a collection
cid = requests.post(f"{BASE}/collections", json={"name": "HR policies"}, headers=headers).json()["id"]

# 2. Upload a PDF
with open("leave-policy.pdf", "rb") as f:
    doc = requests.post(f"{BASE}/collections/{cid}/documents",
                        files={"file": f}, data={"title": "Leave policy"}, headers=headers).json()

# 3. Wait until it is searchable and its section tree is settled
while True:
    s = requests.get(f"{BASE}/collections/{cid}/documents/{doc['id']}/status", headers=headers).json()
    if s["status"] == "failed":
        raise RuntimeError(s["ingest"]["error"])
    if s["status"] == "ready" and s["deep_tree"]["status"] not in ("waiting", "queued", "processing"):
        break
    time.sleep(3)

# 4. Ask a question
answer = requests.post(f"{BASE}/collections/{cid}/answer",
                       json={"query": "كم مدة الإجازة السنوية؟"}, headers=headers).json()
print(answer["answer"])

Ready to Get Started?

Generate an API key from your dashboard and start building

Activate account?

Activate this account?