✨ WHAT IS A KNOWLEDGE BASE?
A Knowledge Base (KB) is an organized collection of documents and web sources that AI uses as exclusive context to answer your questions. Instead of searching the entire web, the AI focuses only on the content that you have selected.
📁 Organization
Group documents by project or topic
🎯 Precision
Answers based only on your content
💰 Token Savings
Pre-analysis of documents to reduce costs
How it works:
Create the Knowledge Base
Assign a name, description and system instructions (e.g. "Act as a legal expert")
Upload the documents
TXT (3 tokens), PDF, DOCX or web sources. The system automatically generates a summary for each document
Query the KB
The AI uses only the summaries and contents of the KB to respond, ignoring general knowledge
Endpoint: POST neuralaiPublicApi with use_kb: true
const response = await fetch("https://app.neuralaiweb.com/functions/neuralaiPublicApi", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
api_key: "LA_TUA_CHIAVE_API",📊 Token Consumption:
- KB Build - TXT: 3 tokens per document (direct extraction + summary)
- KB Build - PDF/DOCX: 5-150 tokens per document (AI extraction + summary, based on characters)
- 🎵 Audio/Video transcription: 10 tokens/minute (audio), 15 tokens/minute (video) - automatic language detection
- 🔗 YouTube URL: 5 tokens + 1 token/1000 chars (extracted subtitles) or 15 tokens/minute (AI fallback)
- 🌐 Web scraping: 5 tokens + 1 token/2000 chars (article extraction from URL)
- KB Query: 15 tokens base, 30 if the context exceeds 40,000 characters (summaries + document content)
- Savings: Up to 70% compared to sending the full text of each document
💡 Practical example:
50 token (one-time)15-30 token100+ token🔢 How to calculate tokens for your KB:
Formula: Total tokens = (TXT × 3) + (PDF/DOCX × 5) + (queries × 15)
💡 Queries with context over 40,000 characters (many documents or web sources) cost 30 tokens instead of 15.
Example: KB with 10 TXT + 10 PDF + 50 queries/month
30 token50 token50 × 15 = 750 token830 token💡 TXT files cost 60% less than PDF/DOCX!
📏 Processing limits
📄 Maximum file size by type
50 MB20 MB30 MB150 MB30 pages · 30,000 characters🧩 Extraction and per-query context
30.00020.00012.0008.000max 5030 token✅ Advantages over traditional RAG:
- No "stuffing": The AI doesn't receive too many confusing text chunks
- Clean context: Only relevant summaries are sent to the model
- Consistent answers: The KB has clear system instructions (e.g. "Reply only based on the documents")
- Predictable costs: You pay once for the analysis, then use the KB unlimitedly
⚙️ docs_only mode:
When you create a KB, you can activate docs_only_mode: true. In this mode:
- The AI responds only using the KB contents
- The model's general knowledge is excluded
- Perfect for technical manuals, business documentation, FAQs
🔌 Connectors for Knowledge Base
Import documents directly from GitHub and Google Drive to enrich your Knowledge Base.
GitHub
- ✓Import README and documentation from repositories
- ✓Supports .md, .txt, .json, .yml, .js, .py and others
- ✓Connect your GitHub account via OAuth
- ✓5 tokens per imported document
Google Drive
- ✓Import PDF, DOCX, TXT directly from Drive
- ✓Automatic summary included (5-10 tokens)
- ✓Connect your Google account via OAuth
- ✓drive.file scope: access only to files used
💡 Tip: Use connectors to automatically sync documentation from your repositories and cloud storage. Each imported file is automatically analyzed and summarized to optimize costs for subsequent queries.
🧪 KB Chat - Complete HTML Code
Complete chat interface with Knowledge Base integration, web search toggle, voice input (microphone), TTS playback and intent detection for media generation. Save it as kb-chat.html and open it.
<!DOCTYPE html> <html lang="it"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
📋 How to use:
- Copy the code above and save it as
kb-chat.html - Also download/copy
kb-chat.jsfrom the "Esempio Chat KB Completo" - Replace
YOUR_API_KEY_HEREin kb-chat.js with your actual API key - Open kb-chat.html in your browser (both files must be in the same folder)
- Enable KB toggle and start chatting with your Knowledge Base!