Guides

Quick Start

Get up and running in 5 minutes

Get up and running with EasyRAG in 5 minutes using real API endpoints.

Prerequisites

Step 1: Get Your API Key

  1. Sign up at easyrag.com
  2. Navigate to Settings → API Keys
  3. Click Generate API Key
  4. Copy and save it securely (shown only once)

Your API key looks like: sk_abc123xyz...

⚠️ Keep your API key secure - store it in environment variables, never commit to Git.

Frontend tokens (optional, recommended for browsers)

For client-side usage, do not expose your API key. Instead, from your backend either call POST https://api.easyrag.com/v1/tokens/create or use client.createToken(datasetId, { ttlSeconds }) from the SDK, then pass the token to your frontend.

Step 2: Upload Your First Document

Upload a PDF to create and index it in a dataset.

Request

bash
curl -X POST https://api.easyrag.com/v1/files/upload \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "datasetId=my-first-dataset" \ -F "file=@document.pdf"

Replace:

  • YOUR_API_KEY with your actual API key
  • document.pdf with your file path

Response

json
{ "success": true, "message": "Files processed and indexed successfully!", "files": [ { "fileId": "f7a3b2c1-4d5e-6f7g", "originalName": "document.pdf", "datasetId": "my-first-dataset", "created": "2024-12-13T10:30:00.000Z" } ], "billed": { "fileCount": 1, "uploadUnits": 10 } }

Cost: 1 credit per file

The file is now indexed and ready to search!

Step 3: Search Your Document

Find relevant content using semantic search.

Request

bash
curl -X POST https://api.easyrag.com/v1/search \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "datasetId": "my-first-dataset", "question": "What is this document about?" }'

Response

json
{ "success": true, "data": [ { "score": 0.89, "pageContent": "This document outlines the key features...", "metadata": { "fileId": "f7a3b2c1-4d5e-6f7g", "originalName": "document.pdf" } } ] }

Cost: 0.1 credit

Step 4: Get an AI Answer

Ask a question and get a ChatGPT-style answer.

Request

bash
curl -X POST https://api.easyrag.com/v1/query \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "datasetId": "my-first-dataset", "question": "Summarize the key points", "stream": false }'

Response

json
{ "success": true, "data": { "result": "Based on the document, the key points are:\n\n1. Automated document processing\n2. Semantic search capabilities\n3. AI-powered question answering\n4. Multi-tenant architecture" } }

Cost: 0.1 credit

What You Just Did

  1. ✅ Created an API key
  2. ✅ Uploaded and indexed a document
  3. ✅ Searched for relevant content
  4. ✅ Got an AI-generated answer

Next Steps

Upload Multiple Files

bash
curl -X POST https://api.easyrag.com/v1/files/upload \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "datasetId=my-first-dataset" \ -F "file=@file1.pdf" \ -F "file=@file2.pdf"

Add Metadata

bash
curl -X POST https://api.easyrag.com/v1/files/upload \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "datasetId=my-first-dataset" \ -F 'metadata={"contract.pdf":{"department":"legal"}}' \ -F "file=@contract.pdf"

Filter by Metadata

bash
curl -X POST https://api.easyrag.com/v1/search \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "datasetId": "my-first-dataset", "question": "contract terms", "filters": [{"key": "department", "match": {"value": "legal"}}] }'

Stream Responses

bash
curl -X POST https://api.easyrag.com/v1/query \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "datasetId": "my-first-dataset", "question": "Explain the main features", "stream": true }'

Using from Code

Node.js (Server-Side)

javascript
const apiKey = process.env.EASYRAG_API_KEY; // Upload const formData = new FormData(); formData.append('datasetId', 'my-first-dataset'); formData.append('file', fs.createReadStream('document.pdf')); await fetch('https://api.easyrag.com/v1/files/upload', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}` }, body: formData }); // Search const searchRes = await fetch('https://api.easyrag.com/v1/search', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ datasetId: 'my-first-dataset', question: 'What is this about?' }) }); const { data } = await searchRes.json(); // Query const queryRes = await fetch('https://api.easyrag.com/v1/query', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ datasetId: 'my-first-dataset', question: 'Summarize this', stream: false }) }); const { data: answer } = await queryRes.json();

Common Issues

"Invalid API key"

  • Ensure key starts with sk_
  • Check for extra spaces
  • Verify it hasn't been revoked

"Insufficient credits"

  • Check balance in dashboard
  • Purchase more credits
  • Uploads cost 1 credit, queries cost 0.1 credit

File upload fails

  • Max 100MB for documents, 2GB for media
  • Supported: .pdf, .docx, .xlsx, .pptx, .csv, .mp3, .wav, .mp4

API Endpoints

EndpointMethodPurposeCost
/v1/files/uploadPOSTUpload files1 credit/file
/v1/filesGETList filesFree
/v1/searchPOSTSearch0.1 credit
/v1/queryPOSTAI answers0.1 credit

Learn More

Support

📧 support@easyrag.com