Docs / Language and text
Search your own documents API
Upload documents, ask a question, get the best passages back: retrieval for your own AI app.
Make a collection, add documents (plain text or Markdown; take a PDF's text with POST /v1/pdf/text first), and query it: the documents are cut into passages, embedded with the multilingual model on this server, and each query's nearest passages are reranked by the cross-encoder. Collections are private to their secret, kept in memory for a day, up to 1,000 passages. The collection demo (secret demo) holds a few facts about India, for trying. Needs a free API key once keys are required (see /keys).
https://api.dharun.devNo key needed for most600 units a minute, 3000 with a free keyThis page as MarkdownMake a collection
POST/v1/rag
Send: Nothing, or {} .
Model endpoint: it will need a free API key, sent as Authorization: Bearer <key> or X-API-Key. Until the date on API keys it answers without one and says so in the X-Key-Notice header. With a key: 500 model requests a day.
What you send here is never written to the log, and the answer is not cached.
curl
curl -H "Content-Type: application/json" --data '{}' "https://api.dharun.dev/v1/rag?utm_medium=docs"JavaScript
const response = await fetch("https://api.dharun.dev/v1/rag?utm_medium=docs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
console.log(body.data);Python
import requests
response = requests.post("https://api.dharun.dev/v1/rag?utm_medium=docs", data="{}", headers={"Content-Type": "application/json"}, timeout=60)
body = response.json()
if not response.ok:
raise RuntimeError(body["error"]["message"])
print(body["data"])invoice.json
{}Try it here
Change the values and send the request from your browser. Needs JavaScript.
Add documents
POST/v1/rag/{id}/documents
Send: JSON {"documents": [{"name": "...", "text": "..."}], "size": 800}: up to 2 MB of text.
Model endpoint: it will need a free API key, sent as Authorization: Bearer <key> or X-API-Key. Until the date on API keys it answers without one and says so in the X-Key-Notice header. With a key: 500 model requests a day.
What you send here is never written to the log, and the answer is not cached.
curl
curl -H "Content-Type: application/json" --data '{"documents": [{"name": "shop rules", "text": "Returns are accepted within 7 days with the bill."}]}' "https://api.dharun.dev/v1/rag/demo/documents?secret=demo&utm_medium=docs"JavaScript
const response = await fetch("https://api.dharun.dev/v1/rag/demo/documents?secret=demo&utm_medium=docs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({"documents": [{"name": "shop rules", "text": "Returns are accepted within 7 days with the bill."}]}),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
console.log(body.data);Python
import requests
response = requests.post("https://api.dharun.dev/v1/rag/demo/documents?secret=demo&utm_medium=docs", data="{\"documents\": [{\"name\": \"shop rules\", \"text\": \"Returns are accepted within 7 days with the bill.\"}]}", headers={"Content-Type": "application/json"}, timeout=60)
body = response.json()
if not response.ok:
raise RuntimeError(body["error"]["message"])
print(body["data"])invoice.json
{"documents": [{"name": "shop rules", "text": "Returns are accepted within 7 days with the bill."}]}Try it here
Change the values and send the request from your browser. Needs JavaScript.
Response
{
"data": {
"added": 0,
"passages": 6
},
"meta": {
"note": "The demo collection is read-only. Make your own with POST /v1/rag."
}
}Ask a question
POST/v1/rag/{id}/query
Send: JSON {"query": "...", "top": 5, "rerank": true}.
Model endpoint: it will need a free API key, sent as Authorization: Bearer <key> or X-API-Key. Until the date on API keys it answers without one and says so in the X-Key-Notice header. With a key: 500 model requests a day.
What you send here is never written to the log, and the answer is not cached.
curl
curl -H "Content-Type: application/json" --data '{"query": "How many digits does a pincode have?", "top": 2}' "https://api.dharun.dev/v1/rag/demo/query?secret=demo&utm_medium=docs"JavaScript
const response = await fetch("https://api.dharun.dev/v1/rag/demo/query?secret=demo&utm_medium=docs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({"query": "How many digits does a pincode have?", "top": 2}),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
console.log(body.data);Python
import requests
response = requests.post("https://api.dharun.dev/v1/rag/demo/query?secret=demo&utm_medium=docs", data="{\"query\": \"How many digits does a pincode have?\", \"top\": 2}", headers={"Content-Type": "application/json"}, timeout=60)
body = response.json()
if not response.ok:
raise RuntimeError(body["error"]["message"])
print(body["data"])invoice.json
{"query": "How many digits does a pincode have?", "top": 2}Try it here
Change the values and send the request from your browser. Needs JavaScript.
Response, with lists and long text shortened
{
"data": {
"passages": [
{
"document": "India API facts",
"passage": 0,
"text": "Pincodes are six digits. The first digit is the postal region, the first two the postal circle, and the first three the sorting district. Tamil Nadu's pincodes …",
"similarity": 0.8904000000000001,
"rerankScore": 0.997982
},
{
"document": "India API facts",
"passage": 2,
"text": "A GSTIN is fifteen characters: the two-digit state code, the holder's PAN, an entity number, the letter Z by default, and a check character.",
"similarity": 0.8344,
"rerankScore": 0.023465
}
],
"query": "How many digits does a pincode have?",
"reranked": true
},
"meta": {
"note": "The passages nearest the query by embedding, then reranked by the cross-encoder. Give these to a language model as context, with their document names."
}
}Delete a collection
POST/v1/rag/{id}/delete
Send: Nothing, or {} .
What you send here is never written to the log, and the answer is not cached.
curl
curl -H "Content-Type: application/json" --data '{}' "https://api.dharun.dev/v1/rag/demo/delete?secret=demo&utm_medium=docs"JavaScript
const response = await fetch("https://api.dharun.dev/v1/rag/demo/delete?secret=demo&utm_medium=docs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.message);
console.log(body.data);Python
import requests
response = requests.post("https://api.dharun.dev/v1/rag/demo/delete?secret=demo&utm_medium=docs", data="{}", headers={"Content-Type": "application/json"}, timeout=60)
body = response.json()
if not response.ok:
raise RuntimeError(body["error"]["message"])
print(body["data"])invoice.json
{}Try it here
Change the values and send the request from your browser. Needs JavaScript.
Response
{
"data": {
"deleted": false,
"id": "demo"
},
"meta": {
"note": "The demo collection is never deleted."
}
}Using an AI assistant? Connect the MCP server and it can call this API by itself. Want every endpoint on one bench? Open the playground.