The simplest and most reliable way to add content is via text upload:

Upload Multiple Texts

import requests

# No authentication required
url = "https://vedaya-kge.fly.dev/documents/texts"

# Upload text documents
documents = [
    "Your first document content here...",
    "Your second document content here...",
    "Your third document content here..."
]

response = requests.post(
    url,
    headers={"Content-Type": "application/json"},  # No auth needed
    json={
        "texts": documents,
        "file_sources": [f"doc_{i}.txt" for i in range(len(documents))]  # Optional
    }
)

if response.status_code == 200:
    print("✅ Documents uploaded successfully")

Upload Single Text

# For single text document
url = "https://vedaya-kge.fly.dev/documents/text"

response = requests.post(
    url,
    headers={"Content-Type": "application/json"},
    json={
        "text": "This is the content to be indexed and made searchable.",
        "file_source": "manual_entry.txt"  # Optional
    }
)

File Upload (Alternative Method)

For PDF, DOCX, and other file formats:

Single File Upload

import requests

url = "https://vedaya-kge.fly.dev/documents/upload"

# Optional authentication
headers = {}
# If you have an API key (optional):
# headers["Authorization"] = f"Bearer {API_KEY}"

with open('document.pdf', 'rb') as f:
    files = {'file': ('document.pdf', f, 'application/pdf')}
    response = requests.post(url, headers=headers, files=files)
    
if response.status_code == 200:
    print("✅ File uploaded successfully")

Direct File Processing

url = "https://vedaya-kge.fly.dev/documents/file"

with open('report.pdf', 'rb') as f:
    files = {'file': ('report.pdf', f, 'application/pdf')}
    response = requests.post(url, files=files)

Batch File Upload

url = "https://vedaya-kge.fly.dev/documents/file_batch"

files = [
    ('files', ('doc1.pdf', open('doc1.pdf', 'rb'), 'application/pdf')),
    ('files', ('doc2.txt', open('doc2.txt', 'rb'), 'text/plain')),
    ('files', ('doc3.docx', open('doc3.docx', 'rb'), 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'))
]

response = requests.post(url, files=files)
# Returns status: "success", "partial_success", or "failure"

Monitor Processing

Processing typically completes in seconds, not minutes:
import time

# Check pipeline status
url = "https://vedaya-kge.fly.dev/documents/pipeline_status"

print("Processing documents...")
for i in range(30):  # Usually completes within seconds
    response = requests.get(url)
    status = response.json()
    
    if not status.get('busy', False):
        print("✅ Processing complete!")
        break
    
    print(f"  Status: {status.get('latest_message', 'Processing...')}")
    time.sleep(2)

Document Operations

View All Documents

url = "https://vedaya-kge.fly.dev/documents"
response = requests.get(url)

if response.status_code == 200:
    docs = response.json()
    # Returns documents grouped by status:
    # {
    #   "statuses": {
    #     "PENDING": [...],
    #     "PROCESSING": [...],
    #     "PROCESSED": [...],
    #     "FAILED": [...]
    #   }
    # }

Clear All Documents

# WARNING: This deletes everything!
url = "https://vedaya-kge.fly.dev/documents"
response = requests.delete(url)

if response.status_code == 200:
    print("✅ All documents cleared")

Clear Cache

url = "https://vedaya-kge.fly.dev/documents/clear_cache"

# Clear specific cache modes
payload = {
    "modes": ["default", "naive", "local", "global", "hybrid", "mix"]
}

response = requests.post(
    url,
    headers={"Content-Type": "application/json"},
    json=payload
)

Scan Input Directory

# Trigger scanning of input directory
url = "https://vedaya-kge.fly.dev/documents/scan"
response = requests.post(url)
# Returns: {"status": "scanning_started", "message": "..."}

Complete Working Example

import requests
import time
from openai import OpenAI

# 1. Upload documents (no auth needed)
documents = [
    "Document about machine learning fundamentals...",
    "Document about neural networks...",
    "Document about deep learning applications..."
]

response = requests.post(
    "https://vedaya-kge.fly.dev/documents/texts",
    json={"texts": documents}
)
print(f"Upload status: {response.status_code}")

# 2. Wait for processing (usually takes seconds)
for i in range(30):
    status = requests.get(
        "https://vedaya-kge.fly.dev/documents/pipeline_status"
    ).json()
    
    if not status.get('busy', False):
        print("✅ Processing complete!")
        break
    time.sleep(2)

# 3. Documents are now ready for querying
client = OpenAI(
    api_key="sk-dummy",
    base_url="https://vedaya-kge.fly.dev/v1"
)

response = client.chat.completions.create(
    model="vedaya-hybrid",
    messages=[{"role": "user", "content": "What topics are covered?"}]
)
print(response.choices[0].message.content)

Important Notes

  • Text upload is fastest - Use /documents/texts for quick ingestion
  • Processing is fast - Usually completes in seconds, not minutes
  • File formats supported - PDF, DOCX, TXT, and other common formats
  • Batch operations available - Upload multiple documents at once