BrainUs LogoBrainUs AI

Quick Start

Get started with BrainUs AI in minutes

Introduction

BrainUs AI is a RAG-powered educational API designed to provide accurate, curriculum-aligned content with verifiable citations. Built for developers creating educational applications, it offers seamless integration with comprehensive documentation coverage.

BrainUsAI API has different parts:

Want to learn more?

Read our in-depth What is BrainUs AI introduction.

Terminology

  • RAG (Retrieval-Augmented Generation): An AI approach that combines document retrieval with language generation to provide accurate, citation-backed answers.

  • Store: A collection of indexed documents. Use "default" for general Sri Lankan curriculum queries.

  • Citation: Source references with document name and page number that verify the accuracy of API responses.

Some basic knowledge of REST APIs and either Python or JavaScript would be useful.

Create Your Account

Sign Up

Visit developers.brainus.lk and create your free account. No credit card required.

Subscribe to a Plan

Go to Upgrade and subscribe to a Free or paid plan. The Free plan requires no credit card! You must have an active subscription before creating API keys.

Generate API Key Navigate to Dashboard → API Keys and click "Create API

Key". Copy it immediately - you won't see it again! The API key will match your current plan.

Make Your First Request

Test your API key with a simple curl command:

curl -X POST "https://api.brainus.lk/api/v1/query" \
  -H "X-API-Key: $BRAINUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What is photosynthesis?",
    "store_id": "default"
  }'

Or try it instantly in our API Playground without writing any code!

Install SDK (Optional)

For Python or JavaScript projects, install our official SDK:

# Python
pip install brainus-ai

# JavaScript/TypeScript
npm install @brainus/ai

Your First Query

Using Python

import asyncio
import os
from brainus_ai import BrainusAI

async def main():
    # Ensure BRAINUS_API_KEY is set in your environment
    api_key = os.getenv("BRAINUS_API_KEY")

    async with BrainusAI(api_key=api_key) as client:
        result = await client.query(
            query="What is photosynthesis?",
            store_id="default"
        )
        print(result.answer)

        # Access citations
        if result.citations:
            for citation in result.citations:
                print(f"Source: {citation.document_name}")
                if citation.pages:
                    print(f"Pages: {', '.join(map(str, citation.pages))}")

if __name__ == "__main__":
    asyncio.run(main())

Using JavaScript

/* Use ESM or TypeScript */
import { BrainusAI } from "@brainus/ai";

/* Or CommonJS */
/* const { BrainusAI } = require("@brainus/ai"); */

// Ensure BRAINUS_API_KEY is set in your environment
const client = new BrainusAI({
  apiKey: process.env.BRAINUS_API_KEY,
});

async function main() {
  const result = await client.query({
    query: "What is photosynthesis?",
    storeId: "default",
  });

  console.log(result.answer);

  // Access citations
  if (result.citations && result.citations.length > 0) {
    result.citations.forEach((citation) => {
      console.log(`Source: ${citation.documentName}`);
      if (citation.pages.length > 0) {
        console.log(`Pages: ${citation.pages.join(", ")}`);
      }
    });
  }
}

main();

Using cURL

curl -X POST "https://api.brainus.lk/api/v1/query" \
  -H "X-API-Key: $BRAINUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What is photosynthesis?",
    "store_id": "default"
  }'

Want to test without code? Try our interactive API Playground to explore the API instantly!

The free plan includes 300 requests per month. Perfect for testing and small projects!

FAQ

Some common questions you may encounter.

Learn More

New here? We welcome your questions and feedback!

If you find anything confusing, please reach out on GitHub or email us at developers@brainus.lk.

Core Documentation

SDKs & Integration

Advanced Topics

On this page