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

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

ParameterTypeRequiredDescription
querystringYesThe question or search query
store_idstringYesKnowledge base identifier (use "default")
filtersobjectNoFilter results by grade, subject, or language
optionsobjectNoAdditional options for the query

Response Format

{
  "answer": "AI-generated answer to your query",
  "citations": [
    {
      "document": "Source document name",
      "page": 45,
      "relevance": 0.95,
      "excerpt": "Relevant excerpt from the document"
    }
  ],
  "metadata": {
    "query_id": "qry_1234567890abcdef",
    "tokens_used": 256,
    "response_time_ms": 342
  }
}

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