Answers with citations
An answer without a source is a claim you have to trust on faith. This endpoint pairs every generated answer with the specific passages it was built from, so a reader — or a compliance reviewer — can check the work in seconds.
Run it online
Run this on our servers with your account. Free tools run in your browser; this one bills your KIT balance per the price above.
Trust is the actual product
A model can produce a fluent, confident answer whether or not that answer is grounded in anything real. That gap is fine for brainstorming and dangerous for anything a customer, a regulator, or a legal team will rely on. rag.answer_sources exists for the second case: teams building support tools, internal knowledge bases, or research assistants who need every sentence traceable to a passage someone can open and read for themselves.
What the request needs and what comes back
POST /rag/answer-sources with a question and the document set or index to search, and the task runs asynchronously — you get a task_id right away and the finished result later, through a signed webhook call or a signed link that stays valid for 24 hours. The response isn't just prose: it's an answer accompanied by the specific passages, with enough locating detail to point back to where in the source material each claim came from.
Retrieval, then generation, not generation alone
This is the retrieval-augmented generation pattern that emerged specifically to fix the ungrounded-answer problem: instead of asking a model to answer purely from what it memorized during training, the system first retrieves the passages most relevant to the question, then generates an answer constrained to what those passages actually say. Citing sources isn't a cosmetic add-on to that pattern — it is the verification step that makes the retrieval step worth doing at all, because a hidden citation is no better than no citation.
Fitting it into a pipeline
Because the task is billed per request plus per query and runs async, it drops cleanly into a batch job that answers a backlog of questions overnight, or into a live tool where a single query resolves in the background while your interface does something else. A failed task costs nothing — three retries happen automatically before you see a clear error — so a queue of a thousand questions behaves predictably even when a handful hit edge cases.
Who reaches for this over a plain chat answer
Anyone who has to defend an answer later. A support team documenting how they arrived at a policy interpretation, a research group building a literature assistant, or a legal or compliance function reviewing contract language all need the underlying passage, not just the summary. Cited answers turn a chatbot from an oracle you hope is right into a research tool whose output you can actually check.
What you can do with it
Policy interpretation with an audit trail
An HR team asks about a benefits rule and gets both the answer and the exact clause in the policy document it came from, ready to attach to a ticket.
Research assistant over a paper collection
A research group queries a set of papers and receives an answer with the passages cited, so a reviewer can verify the claim before it goes into a report.
Legal contract review
A legal team asks whether a clause exists in a contract set and gets a cited answer pointing to the exact section, cutting down manual document review.
Customer support with verifiable answers
A support platform answers a billing question and shows the agent the source passage alongside the answer, so the agent can quote it with confidence.
FAQ
How does the RAG with sources API work?
POST a question and your document set to /rag/answer-sources, and you get back an answer along with the specific passages that support it, delivered by webhook or a signed link valid for 24 hours.
Is the cited RAG API free to use?
No, there is no free tier or trial; it costs $0.003 per request plus $0.015 per query, and a failed task is never charged.
What makes this different from a normal RAG answer?
Every answer comes paired with the exact source passages it draws from, not just a generated summary, so you can verify the claim instead of trusting it blindly.
Can I use this for compliance or legal review?
Yes, because each answer points back to the specific passage it came from, it's built for exactly the situations where you need to show your work.
What document formats can I search?
Any document set or index you provide as part of the request; the endpoint retrieves relevant passages from it before generating the cited answer.
Can I run this on a large batch of questions?
Yes, submit one async task per question and collect results by webhook as each finishes, which scales cleanly to large batches.
Is this endpoint live?
Yes, /rag/answer-sources is live and accepting production traffic now.
Is my document data kept after the query?
No, submitted documents and results are deleted after the retention window and are never used for training.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/rag/answer-sources \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"…"}'const res = await fetch("https://api.kit.forhosting.com/rag/answer-sources", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"input": "…"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/rag/answer-sources",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"input": "…"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/rag/answer-sources", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"input":"…"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"input":"…"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/rag/answer-sources", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"input": "…"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "rag.answer_sources",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_chunks | 10000 |
max_tokens | 20000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
422 | task_failed | The task failed after 3 retries. You are never charged for it. |