# ask: RAG – Ask Knowledge Base (AI Answer with Sources)

> ask (RAG – Ask Knowledge Base (AI Answer with Sources)) is a 1001fx API function in the group Knowledge bases (RAG): POST https://api.1001fx.com/rag/ask, 4 credits per item. It works as a ready-made module in Make or as a plain HTTP call.

Answers a question from the documents of a knowledge base, with the passages used as sources. The AI answers only from the documents and says when the answer is not in them; text in documents that addresses an AI is not followed (sources[].injectionSuspected). 4 credits per started 1,000 tokens (question, passages and answer), twice that with gpt-6.1-terra.

- Group: Knowledge bases (RAG)
- Endpoint: `POST https://api.1001fx.com/rag/ask`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 4 credits per item
- Ready-made in: Make
- Docs: https://1001fx.com/functions/ask

## Parameters

- `knowledgeBase` (string, required) – Knowledge base: Name or ID of the knowledge base, e.g. "Support FAQ" or support-faq (same knowledge base). rag/adddocument creates it if it does not exist.
- `question` (string, required) – Question
- `topK` (number, optional, default `5`, min 1, max 20) – Passages: Passages given to the AI, 1-20 (default 5).
- `model` (enum, optional, one of `gpt-6-luna`, `gpt-6.1-terra`, default `gpt-6-luna`) – Model: gpt-6-luna (default) or gpt-6.1-terra for harder questions (twice the credits).
- `systemMessage` (string, optional) – Instructions: Tone, format, length or language of the answer, e.g. "Answer in two sentences, formal German."
- `maxTokens` (number, optional, min 16, max 8000) – Max answer tokens: Limits the length of the answer.
- `minScore` (number, optional, min 0, max 1) – Minimum score: Leave out passages below this similarity (0-1).
- `includeMetadataInPrompt` (any, optional) – Include metadata in prompt: Off by default. Sends the metadata of the found documents to the AI together with the text, e.g. so the answer can mention the validity or the product. `true` sends all keys, a list sends only these keys, e.g. ["validUntil", "product"]. Every key costs tokens (credits) and is sent to the AI (Azure OpenAI, EU) – only include what helps the answer. Filtering does not need it.
- `citations` (boolean, optional, default `false`) – Citations: Marks each statement of the answer with the sources it comes from, e.g. [1] or [2][3] – [n] is sources[n-1].
- `filter` (any, optional) – Filter: Only documents whose metadata match. Object {"department": "billing", "lastModified": {"$gte": "2026-01-01"}} (operators $eq $ne $in $nin $gt $gte $lt $lte $exists $contains, $and $or $not) or array [{"key", "operator", "value", "type"}] (all must match).
- `filterJson` (string, optional) – Filter (JSON): The filter as JSON text, e.g. for OR conditions from Make: {"$or": [{"department": "billing"}, {"department": "sales"}]}.

## Example: RAG – Ask Knowledge Base (AI Answer with Sources)

```bash
curl -X POST 'https://api.1001fx.com/rag/ask' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"knowledgeBase":"Support FAQ","question":"How do I cancel my subscription?"}'
```
