Knowledge (RAG) API
Give your agents your documents, and they answer from them — with citations from your content instead of guesses. Knowledge lives in collections: named sets of documents, embedded into a vector index, searchable by meaning in Arabic and English alike.
Build a collection
# 1. create it
curl -X POST https://platform.senaiy.ai/v1/collections \
-H "Authorization: Bearer sk-sf-..." \
-d '{"collection_code": "handbook", "collection_name": "HR Handbook",
"embedding_model": "openai-text-embedding-3-large"}'
# 2. upload a file (base64 body; PDF, DOCX, TXT, …)
curl -X POST https://platform.senaiy.ai/v1/files \
-H "Authorization: Bearer sk-sf-..." \
-d '{"file_name": "policy.pdf", "content_base64": "..."}'
# → {"message": {"id": "...", "status": "uploaded", "checksum": "...", "size_bytes": ...}}
# 3. attach it — parsing, chunking and embedding run automatically
curl -X POST https://platform.senaiy.ai/v1/collections/{id}/documents \
-H "Authorization: Bearer sk-sf-..." \
-d '{"file_id": "..."}'
Search it
curl -X POST https://platform.senaiy.ai/v1/collections/{id}/search \
-H "Authorization: Bearer sk-sf-..." \
-d '{"query": "سياسة الإجازات السنوية"}'
Results are the most relevant chunks with their source files — use them directly, or as context for a chat completion (classic RAG).
The better way: attach to an agent
You can orchestrate RAG yourself, but the platform does it for you: attach the collection to an agent in the portal and the agent searches it automatically when a question needs it — and tells the model what the collection contains, so it actually gets used. Your code goes back to one call: run the agent.
Storage and vector quotas are per plan; exceeding them returns
storage_quota_exceeded rather than degrading quietly.