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:
Query API
The core endpoint for retrieving educational content from our knowledge base with AI-powered search and verified citations.
Usage API
Track your API usage, monitor quotas, and analyze performance metrics in real-time.
Plans API
Retrieve information about available plans, pricing, and upgrade options programmatically.
SDKs & Libraries
Official Python and JavaScript SDKs with full TypeScript support, automatic retry handling, and rate limit management.
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/aiYour 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
What is BrainUs AI
Complete overview of BrainUs AI features and capabilities
Authentication
Learn how to securely manage API keys
Query API
Complete API reference with request/response schemas
Code Examples
Production-ready examples in Python and JavaScript
SDKs & Integration
Python SDK
Full-featured SDK with type hints and async support
JavaScript/TypeScript SDK
Node.js SDK with complete TypeScript definitions
Python Examples
Django, Flask, FastAPI integration examples
JavaScript Examples
Next.js, React, Express integration examples