A multi-tenant RAG API over a dense index and a knowledge graph, with speaker-aware
transcription built in. It speaks the OpenAI protocol, so every client you already
have works unchanged — only the base_url moves.
Authenticate with the API key issued for your tenant. Every response carries citations back to the exact chunk — and, for audio, the speaker and timestamp.
# pip install openai
from openai import OpenAI
client = OpenAI(
base_url="https://ai.2brother.in/v1",
api_key="rag_live_…",
)
r = client.chat.completions.create(
model="qwen3:8b",
messages=[{"role": "user",
"content": "What did we agree with Acme on pricing?"}],
)
print(r.choices[0].message.content)
# citations ride along on the response
print(r.model_extra["citations"])// npm i openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://ai.2brother.in/v1",
apiKey: process.env.RAG_API_KEY,
});
const stream = await client.chat.completions.create({
messages: [{ role: "user", content: "Summarise yesterday's call." }],
stream: true,
});
for await (const part of stream) {
process.stdout.write(part.choices[0]?.delta?.content ?? "");
}curl https://ai.2brother.in/v1/chat/completions \
-H "Authorization: Bearer $RAG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role":"user","content":"Who owns the Acme renewal?"}],
"rag": { "use_graph": true, "top_k": 8 }
}'
# retrieval only, no generation
curl https://ai.2brother.in/v1/search \
-H "Authorization: Bearer $RAG_API_KEY" \
-d '{"query":"renewal terms","top_k":5}'# Upload a recording. Deepgram diarizes it; every chunk keeps
# its speaker and time window, so answers cite the moment.
curl https://ai.2brother.in/v1/ingest/file \
-H "Authorization: Bearer $RAG_API_KEY" \
-F "file=@standup.m4a" \
-F 'meta={"collection":"calls","deal":"acme"}'
# or hand us a URL — the bytes never touch our server
curl https://ai.2brother.in/v1/ingest/url \
-H "Authorization: Bearer $RAG_API_KEY" \
-d '{"url":"https://cdn.example.com/call.mp3"}'
# poll until status = ready
curl https://ai.2brother.in/v1/documents/$DOC_ID \
-H "Authorization: Bearer $RAG_API_KEY"Dense and lexical search disagree usefully. Fusing them on rank, then widening through the graph, surfaces sources that keyword matching alone would miss.
Follow-ups get resolved into standalone queries, and named things are pulled out for graph lookup.
pgvector HNSW cosine search alongside Postgres full-text, fused with reciprocal rank fusion.
Entities in the top hits are walked out two hops in Neo4j, pulling in connected chunks that share no keywords.
Maximal marginal relevance drops near-duplicates so the context window carries distinct evidence.
A local model answers strictly from context and cites each claim — speaker and timestamp for audio.
Tokens, audio seconds and cost land in an append-only ledger, per tenant, per key.
Full schemas, request bodies and try-it-now live in the interactive reference.