Get Started with Vedaya
Follow this guide to quickly set up and start using the Vedaya API for document processing, knowledge graph creation, and RAG-powered applications.
Prerequisites
Before you begin, make sure you have:
- A Vedaya account (sign up at app.vedaya.ai if you don’t have one)
- An API key (available in your Vedaya dashboard)
- Python 3.8+ installed (for using the Python examples)
Installation
You can use the Vedaya API with any programming language that can make HTTP requests. For Python users, we recommend using the requests
library:
Authentication
All API requests require authentication with your API key:
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
Replace YOUR_API_KEY
with your actual API key from the Vedaya dashboard.
Basic Workflow
The typical workflow for using Vedaya consists of these steps:
- Upload Documents: Ingest documents through file upload or cloud integration
- Process Documents: Extract text, chunk content, and generate embeddings
- Build Knowledge Graph: Extract entities and relationships
- Query Knowledge: Retrieve information and generate answers
Let’s implement each of these steps.
Step 1: Upload Documents
import requests
url = "https://vedaya-backend.fly.dev/api/data-ingestion/upload-files"
# Prepare files and parameters
files = [
('files', ('document.pdf', open('document.pdf', 'rb'), 'application/pdf'))
]
data = {
'chunk_size': 500,
'overlap_pct': 10
}
# Add your API key
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
# Send request
response = requests.post(url, headers=headers, files=files, data=data)
file_id = response.json()['file_ids'][0]
print(f"Uploaded document with ID: {file_id}")
Step 2: Check Processing Status
import requests
import time
url = f"https://vedaya-backend.fly.dev/api/data-ingestion/status/{file_id}"
headers = {
'Authorization': 'Bearer YOUR_API_KEY'
}
# Poll status until processing completes
while True:
response = requests.get(url, headers=headers)
status = response.json()['status']
print(f"Processing status: {status}")
if status in ['completed', 'failed']:
break
time.sleep(5) # Wait 5 seconds before checking again
Step 3: Detect Entities
import requests
import json
url = "https://vedaya-backend.fly.dev/api/knowledge-graph/detect-entities"
payload = json.dumps({
"document_ids": [file_id]
})
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=payload)
print("Entity detection started")
# Check entity detection status
url = "https://vedaya-backend.fly.dev/api/knowledge-graph/entity-detection-status"
while True:
response = requests.get(url, headers=headers)
status = response.json()['status']
print(f"Entity detection status: {status}")
if status in ['completed', 'failed']:
break
time.sleep(5)
Step 4: Query Your Knowledge Base
import requests
import json
url = "https://vedaya-backend.fly.dev/api/retrieval/query"
payload = json.dumps({
"query": "What are the main topics covered in the document?",
"top_k": 3,
"model": "gpt-4"
})
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=payload)
result = response.json()
print("Generated Answer:")
print(result['answer'])
print("\nRetrieved Chunks:")
for i, chunk in enumerate(result['chunks']):
print(f"Chunk {i+1}: {chunk['text'][:100]}... (Score: {chunk['score']})")
Next Steps
Congratulations! You’ve completed the basic workflow for using the Vedaya API. From here, you can:
- Explore the Data Ingestion Guide for more upload options
- Learn about Knowledge Graph visualization and management
- Dive into Vector Indexing to understand how embeddings work
- Implement Retrieval & RAG in your applications
API Reference
For detailed API documentation, check out: