Guides
Get up and running in 5 minutes
Get up and running with EasyRAG in 5 minutes using real API endpoints.
Your API key looks like: sk_abc123xyz...
⚠️ Keep your API key secure - store it in environment variables, never commit to Git.
Upload a PDF to create and index it in a dataset.
bashcurl -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 keydocument.pdf with your file pathjson{ "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!
Find relevant content using semantic search.
bashcurl -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?" }'
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
Ask a question and get a ChatGPT-style answer.
bashcurl -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 }'
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
bashcurl -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"
bashcurl -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"
bashcurl -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"}}] }'
bashcurl -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 }'
javascriptconst 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();
pythonimport requests import os api_key = os.environ['EASYRAG_API_KEY'] headers = {'Authorization': f'Bearer {api_key}'} # Upload files = {'file': open('document.pdf', 'rb')} upload_res = requests.post( 'https://api.easyrag.com/v1/files/upload', headers=headers, data={'datasetId': 'my-first-dataset'}, files=files ) # Search search_res = requests.post( 'https://api.easyrag.com/v1/search', headers={**headers, 'Content-Type': 'application/json'}, json={ 'datasetId': 'my-first-dataset', 'question': 'What is this about?' } ) # Query query_res = requests.post( 'https://api.easyrag.com/v1/query', headers={**headers, 'Content-Type': 'application/json'}, json={ 'datasetId': 'my-first-dataset', 'question': 'Summarize this', 'stream': False } )
"Invalid API key"
sk_"Insufficient credits"
File upload fails
| Endpoint | Method | Purpose | Cost |
|---|---|---|---|
/v1/files/upload | POST | Upload files | 1 credit/file |
/v1/files | GET | List files | Free |
/v1/search | POST | Search | 0.1 credit |
/v1/query | POST | AI answers | 0.1 credit |