BrainUs LogoBrainUs AI
Query API

Query API

Query the BrainUs knowledge base with RAG-powered search

The Query API is the core endpoint for retrieving educational content from the BrainUs knowledge base. It uses Retrieval-Augmented Generation (RAG) to provide accurate answers with verifiable citations.

Endpoint

POST /api/v1/dev/query

Base URL: https://api.brainus.lk

Authentication

All requests require authentication using your API key. See Authentication for details.

X-API-Key: $BRAINUS_API_KEY

Quick Example

Get started with our official SDKs or use direct HTTP requests:

import asyncio
from brainus_ai import BrainusAI

async def main():
    client = BrainusAI(api_key="your_api_key")

    response = await client.query(
        query="What is photosynthesis?"
    )

    print(response.answer)
    for citation in response.citations:
        print(f"Source: {citation.document_name}")

asyncio.run(main())
import { BrainusAI } from '@brainus/ai';

const client = new BrainusAI({ apiKey: 'your_api_key' });

const response = await client.query({
  query: 'What is photosynthesis?'
});

console.log(response.answer);
response.citations.forEach(citation => {
  console.log(`Source: ${citation.documentName}`);
});
curl -X POST https://api.brainus.lk/api/v1/dev/query \
  -H "X-API-Key: $BRAINUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What is photosynthesis?",
    "store_id": "default"
  }'

Request Parameters

Prop

Type

Response Format

Response Body

Prop

Type

Citation Object

Prop

Type

Example Response:

{
  "answer": "Great question! Python is a high-level, interpreted programming language...",
  "citations": [
    {
      "document_id": "",
      "document_name": "al-ict-lesson09-ictfromabc.pdf",
      "pages": [1, 2, 3],
      "metadata": null,
      "chunk_text": "--- PAGE 1 ---\n\nPython is a high-level, interpreted programming language..."
    }
  ],
  "has_citations": true
}

All responses include citations from official Sri Lankan curriculum documents, ensuring verifiable answers.

Next Steps

Rate Limits

Query API requests count against your rate limits:

PlanRequests/minRequests/dayRequests/month
Free10300300
Starter202,0002,000
Pro6010,00010,000
Enterprise20050,00050,000

On this page