Welcome to Graphlit! This quickstart gets you from zero to a working AI application in 15 minutes. You'll ingest a PDF, run semantic search, and build a RAG-powered chat interface.
What You'll Build
By the end of this guide, you'll have:
- A Graphlit project set up
- Content ingested and indexed
- Working semantic search
- A chat interface that answers questions about your content
Time required: 15 minutes
Prerequisites: Node.js installed, basic TypeScript knowledge
Step 1: Create Graphlit Account (2 min)
- Go to portal.graphlit.dev
- Sign up (free tier available)
- Create an Organization
- Create a Project
Save these IDs:
- Organization ID
- Environment ID
- Project ID
Step 2: Install SDK (1 min)
npm install graphlit-client
# or
yarn add graphlit-client
Step 3: Initialize Client (1 min)
import { Graphlit } from 'graphlit-client';
const graphlit = new Graphlit(
'your-organization-id',
'your-environment-id',
'your-project-id'
);
console.log('✓ Graphlit client initialized');
Tip: Store IDs in environment variables:
const graphlit = new Graphlit(
process.env.GRAPHLIT_ORGANIZATION_ID!,
process.env.GRAPHLIT_ENVIRONMENT_ID!,
process.env.GRAPHLIT_PROJECT_ID!
);
Step 4: Ingest Your First Document (3 min)
Let's ingest a PDF about AI:
async function ingestDocument() {
// Ingest PDF from URL
const content = await graphlit.ingestUri(
'https://arxiv.org/pdf/2301.00001.pdf',
'AI Research Paper'
);
console.log('Ingested content ID:', content.ingestUri.id);
// Wait for processing to complete
let isDone = false;
while (!isDone) {
const status = await graphlit.isContentDone(content.ingestUri.id);
isDone = status.isContentDone.result;
if (!isDone) {
console.log('Processing...');
await new Promise(r => setTimeout(r, 2000));
}
}
console.log('✓ Content indexed and searchable!');
return content.ingestUri.id;
}
const contentId = await ingestDocument();
What happened:
- PDF downloaded
- Text extracted using AI
- Embeddings generated
- Content indexed in vector database
✅ Quick Win: You can ingest any public URL—PDFs, web pages, YouTube videos, even entire GitHub repos. Just pass the URL to
ingestUri().
Step 5: Your First Search (2 min)
Now search the content semantically:
async function searchContent(query: string) {
const results = await graphlit.queryContents({
search: query,
limit: 5
});
console.log(`\nSearch results for: "${query}"\n`);
results.contents.results.forEach((content, i) => {
console.log(`${i + 1}. ${content.name}`);
console.log(` Relevance: ${(content.relevance * 100).toFixed(1)}%`);
// Show preview from first chunk
const preview = content.pages?.[0]?.chunks?.[0]?.text?.substring(0, 150);
console.log(` Preview: ${preview}...\n`);
});
}
await searchContent('What is machine learning?');
Example output:
Search results for: "What is machine learning?"
1. AI Research Paper
Relevance: 94.2%
Preview: Machine learning is a subset of artificial intelligence that enables systems to learn patterns from data without explicit programming...
Try these queries:
- "neural networks"
- "deep learning applications"
- "training models"
💡 Pro Tip: Graphlit uses hybrid search by default (vector + keyword). You get semantic understanding AND exact phrase matching automatically. Learn more in the Search Guide.
Step 6: Build Your First Chat Interface (5 min)
Create a RAG-powered Q&A system:
async function chatWithContent(question: string) {
// Create conversation
const conversation = await graphlit.createConversation('My First Chat');
const conversationId = conversation.createConversation.id;
console.log(`\nQuestion: ${question}`);
// Ask question
const response = await graphlit.promptConversation(question, conversationId);
const answer = response.promptConversation?.message?.message;
const citations = response.promptConversation?.message?.citations;
console.log(`Answer: ${answer}\n`);
// Show sources
console.log('Sources:');
citations?.forEach((citation, i) => {
console.log(` [${i + 1}] ${citation.content?.name} (page ${citation.startPage})`);
});
}
await chatWithContent('Explain the main concepts in this paper');
Example output:
Question: Explain the main concepts in this paper
Answer: This paper discusses three main concepts in machine learning: 1) Supervised learning, where models learn from labeled data, 2) Neural network architectures, particularly deep learning approaches, and 3) Training methodologies including gradient descent and backpropagation.
Sources:
[1] AI Research Paper (page 3)
[2] AI Research Paper (page 7)
[3] AI Research Paper (page 12)
✅ Quick Win: Every answer automatically includes citations—no configuration needed. Citations show which pages/documents were used to generate the answer.
Step 7: Add Streaming for Real-Time Responses (2 min)
Make chat feel like ChatGPT:
async function streamingChat(question: string) {
console.log(`\nQuestion: ${question}\n`);
console.log('Answer: ');
let fullAnswer = '';
await graphlit.streamAgent(
question,
async (event) => {
switch (event.type) {
case 'message_update':
// Print text as it streams
process.stdout.write(event.message.message);
fullAnswer += event.message.message;
if (!event.isStreaming) {
console.log('\n\n✓ Complete');
}
break;
case 'error':
console.error('Error:', event.error.message);
break;
}
}
);
}
await streamingChat('What are the key findings?');
What you see:
Question: What are the key findings?
Answer: The key findings demonstrate that machine learning models can achieve 95% accuracy when trained on domain-specific data...
(Text appears word-by-word in real-time)
Complete Starter Application
Here's everything combined:
import { Graphlit } from 'graphlit-client';
const graphlit = new Graphlit(
process.env.GRAPHLIT_ORGANIZATION_ID!,
process.env.GRAPHLIT_ENVIRONMENT_ID!,
process.env.GRAPHLIT_PROJECT_ID!
);
async function main() {
console.log('=== Graphlit Quickstart ===\n');
// 1. Ingest document
console.log('Step 1: Ingesting document...');
const content = await graphlit.ingestUri(
'https://arxiv.org/pdf/2301.00001.pdf',
'Research Paper'
);
// Wait for completion
let isDone = false;
while (!isDone) {
const status = await graphlit.isContentDone(content.ingestUri.id);
isDone = status.isContentDone.result;
if (!isDone) await new Promise(r => setTimeout(r, 2000));
}
console.log('✓ Document indexed\n');
// 2. Search
console.log('Step 2: Searching...');
const searchResults = await graphlit.queryContents({
search: 'machine learning',
limit: 3
});
console.log(`✓ Found ${searchResults.contents.results.length} results\n`);
// 3. Chat
console.log('Step 3: Asking question...');
const conversation = await graphlit.createConversation('Demo');
console.log('\nQuestion: What are the main concepts?\n');
console.log('Answer: ');
await graphlit.streamAgent(
'What are the main concepts in this paper?',
async (event) => {
if (event.type === 'message_update') {
process.stdout.write(event.message.message);
}
},
conversation.createConversation.id
);
console.log('\n\n✓ Done!');
}
main().catch(console.error);
Run it:
node quickstart.js
What You Just Built
Congratulations! You've built a production-grade RAG application with:
✓ Document ingestion - Automatic text extraction and embedding
✓ Semantic search - Find content by meaning, not keywords
✓ RAG chat - LLM answers grounded in your documents
✓ Source citations - Every answer shows which pages it came from
✓ Real-time streaming - ChatGPT-style typing animation
Next Steps
Now that you have the basics, explore advanced features:
Customize Processing:
- Workflows Guide - Extract entities, generate summaries
- AI Models Guide - Choose GPT-4, Claude, or Gemini
Auto-Sync Content:
- Data Connectors Guide - Connect Slack, Gmail, Google Drive, etc.
Advanced Search:
- Complete Search Guide - Filters, entity queries, performance
Build Knowledge Graphs:
- Knowledge Graphs Guide - Extract people, companies, relationships
Production Ready:
- Production Architecture - Multi-tenant, monitoring, scaling
Common First Issues
Issue: "Content still processing after 5 minutes"
- Large PDFs (100+ pages) can take 5-10 minutes
- Check content state:
await graphlit.getContent(contentId)
Issue: "No search results"
- Wait for indexing to complete (
isContentDone) - Try broader queries first
Issue: "Chat gives generic answers"
- Make sure content is indexed
- Try more specific questions
Get Help
- Documentation: docs.graphlit.dev
- Discord: discord.gg/ygFmfjy3Qx
- GitHub: github.com/graphlit
Welcome to Graphlit! Happy building! 🚀