REST API v1
A stateful, session-based REST API for document Q&A. Upload any document, build a FAISS vector index, and query it with LLaMA 3.1 8B — all in three HTTP calls.
- Base URL
- https://kerdosdotio-kerdos-llm-rag-api.hf.space
- Auth
- hf_token in body (chat only)
- Session TTL
- 60 minutes (configurable)
Endpoints
All Endpoints
POST
/sessions
Create a new isolated session. Returns a session_id.
Response
GET
/sessions/{id}
Get the status and metadata of an existing session.
Response
DELETE
/sessions/{id}
Delete the session and free all in-memory resources (FAISS index + documents).
Response
POST
/sessions/{id}/documents
Upload and index one or more files. Supported: PDF, DOCX, TXT, MD, CSV (max 50 MB each).
Body
Response
POST
/sessions/{id}/chat
hf_tokenAsk a question. Returns a grounded answer generated only from the uploaded documents. Optionally pass hf_token to use production LLaMA inference.
Body
Response
DELETE
/sessions/{id}/history
Clear the conversation history for a session (keeps the indexed documents).
Response
GET
/health
Health check. Returns API status and version.
Response
Code Samples
Typical Integration Workflow
Create session → upload document → ask question → delete session. Three steps, three endpoints.
Configuration
Authentication & Environment Variables
HuggingFace Token (hf_token)
Required only for the POST /sessions/{id}/chat endpoint. The token is passed in the JSON request body — never as a header.
Must have read access to
meta-llama/Llama-3.1-8B-Instruct (accept the licence on HuggingFace)| Variable | Default | Description |
|---|---|---|
| HF_TOKEN | — | HuggingFace token for LLaMA inference |
| SESSION_TTL_MINUTES | 60 | Session auto-expiry in minutes |
| MAX_UPLOAD_MB | 50 | Max file size per upload in MB |
Security Best Practice
Never expose
hf_token in client-side code. Use a Next.js API route or server action as a proxy to keep your token server-side. For enterprise deployments, replace hf_token with your own OAuth2 / API key system.Ready to integrate?
Try the demo now or contact us for a private, on-premise enterprise deployment with your own models and infrastructure.