# RAG

Knowledge bases from files, audio, websites and APIs that your agents query over an HTTP API or MCP, with one key per agent.

Source: https://ardumaker.com/en/docs/rag/

- Category: AI and agents
- Status: Available
- Requirements: An ArduMaker account and a company: creating the RAG, loading content and authorizing agents is done by a company admin; An active Router IA key in the company; if there is none, one is created with the RAG (it needs a payment method or balance); The company up to date with its payments for the RAG to answer
- MCP tools (Read only): `listar_rags`, `ver_rag`, `consultar_rag`

## What can you do with it?

- Gather files (PDF, DOCX, XLSX, CSV, text...), audio, public websites, real-time APIs and free text into one knowledge base.
- Let your agents query it over the **HTTP API** (`POST /api/v1/rags/consultar/`) or as the RAG's own **MCP server**.
- Pick the answer mode on every query: `fragmentos`, `llm` or `mixto`.
- Make it **public** (queried with its ID only, no key) or **limited** (it asks for the general key or an agent's key).
- Give each agent its own key, for API, MCP or both, and revoke it without touching the others.
- Copy a RAG to another language: its sources are translated before being vectorized. Languages: `es`, `en`, `pt`, `fr`, `it`, `de`, `ca` and `nl`.

## When should you use it?

- A support bot that answers with the company's manuals, policies and FAQs.
- An agent in Claude, Cursor or another MCP client that needs internal documentation without pasting it into every chat.
- Data that changes all the time (stock, prices, bookings) served by a live API next to fixed documents.
- A public website worth keeping indexed and re-read every few days on its own.

## How does it work in ArduMaker?

### Create a RAG in the panel

1. Go to [my.ardumaker.com](https://my.ardumaker.com), pick the company and open **Development → APIs → RAG**.
2. Click **New RAG** and fill in the name, information (what it is about), language and visibility (public or limited). Optional: how often websites and APIs are re-read (every 7 days by default, 0 for never), the website reading depth (2) and the maximum pages per website (50).
3. When it is created, the **general key** (`rgk_...`) is shown only once: save it. If it is lost, rotate it and a new one is issued.
4. In **Content**, upload files and audio or add a website, an API or a text. Each source is queued and goes through pending, processing and ready (or error).
5. In **Access** you copy the RAG ID, authorize agents with their own key and see the examples to connect them over API and MCP.
6. In **Try it** you ask a question as an agent would, with the mode and model you want.

### What you can load

| Source | How it is loaded | What ArduMaker does |
| --- | --- | --- |
| File | Uploaded from the panel | PDF, DOCX, XLSX, CSV/TSV, TXT, MD, JSON, HTML, XML, YAML, RTF, SRT/VTT and more. Up to 90 MB per file; photos and videos are rejected. |
| Audio | Uploaded from the panel | MP3, M4A, WAV, OGG, OPUS, FLAC and AAC: transcribed in chunks, then the text is vectorized. |
| Website | A public URL | Reads the page and the links on the same domain, up to the RAG's depth and maximum pages. It is re-read on its own. |
| API | URL, method (`GET` or `POST`), headers, body and “Query live” | Headers are stored encrypted. Live, it is called on every query and its answer is added as one more fragment; otherwise it is indexed and re-read like a website. |
| Text | Pasted in the panel | Vectorized as is. |

Each source is read, translated into the RAG's language when needed, split into fragments and vectorized with the company's Router IA key. URLs are checked so they cannot point to internal addresses, on every redirect too.

## What actually changes?

- The RAG is created with its unique ID (a UUID) and its general key. Only a fingerprint of the key is stored: it cannot be shown again.
- If the company has no active Router IA key, one called “RAG - <company>” is created. If that is not possible (no payment method or balance), the RAG is created anyway, shows the reason and retries on its own.
- The RAG stays **not processed** while any source is pending, processing or failed (or the AI key is missing), and becomes **processed** when all of them are ready.
- Embeddings, transcriptions, translations and the answers of the `llm` and `mixto` modes are paid with the company's Router IA key.
- Every query adds to the RAG's daily usage and, if it came in with an agent's key, to that agent's counter and last use.

## Visibility and keys

| Visibility | Who can query | What they send |
| --- | --- | --- |
| Public | Anyone with the RAG ID | Just the `rag_id` (or the MCP URL), no key |
| Limited (default) | Whoever has a valid key | The RAG's general key or an authorized agent's key |

- **General key** (`rgk_...`): works over API and MCP. **Rotate key** replaces it and invalidates the old one.
- **Per-agent key** (`rgk_...`): created in **Access → Authorize agent** with a name and a channel: `api`, `mcp` or `ambos` (both). It is shown only once and can be revoked or reactivated without touching the others.
- The key goes in the `Authorization` header as is: `Authorization: rgk_...`. The `Bearer ` prefix is accepted too.
- On a public RAG the key is optional: if sent, it is checked and the usage is recorded on that agent.

> **PRECAUCION:** Anyone with its ID can query a public RAG, and every query spends the company's Router IA key. If the content is internal, keep it limited.

## Query over the HTTP API

`POST https://api.ardumaker.com/api/v1/rags/consultar/` with a JSON body. It does not use an ArduMaker session: the door is the key (or none, if the RAG is public).

| Field | Required | What it is |
| --- | --- | --- |
| `rag_id` | Yes | The RAG's unique ID (a UUID), the one you copy in **Access** |
| `pregunta` | Yes | The question, up to 4000 characters |
| `modo` | No | `fragmentos` (default), `llm` or `mixto` |
| `modelo` | With `llm` and `mixto` | An OpenRouter model id, for example `openai/gpt-4o-mini`. Paid with the company's Router IA key |
| `top_k` | No | How many fragments to retrieve: 1 to 20, 5 by default |

### Limited RAG: fragments only

```bash
curl -X POST https://api.ardumaker.com/api/v1/rags/consultar/ \
  -H "Authorization: rgk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "rag_id": "<RAG_ID>",
    "pregunta": "What is the refund policy?",
    "modo": "fragmentos",
    "top_k": 5
  }'
```

### Public RAG: written answer plus fragments

```bash
curl -X POST https://api.ardumaker.com/api/v1/rags/consultar/ \
  -H "Content-Type: application/json" \
  -d '{
    "rag_id": "<RAG_ID>",
    "pregunta": "What is the refund policy?",
    "modo": "mixto",
    "modelo": "openai/gpt-4o-mini"
  }'
```

### The response

```json
{
  "success": true,
  "menssage": "Answer",
  "data": {
    "rag_id": "3f2b9c1e-8a4d-4b6f-9e21-5c7d0a1b2c3d",
    "idioma": "en",
    "modo": "mixto",
    "modelo": "openai/gpt-4o-mini",
    "respuesta": "You can ask for a refund within 30 days of the purchase...",
    "fragmentos": [
      {
        "texto": "Refunds are requested within 30 days...",
        "fuente_id": 12,
        "fuente": "policies.pdf",
        "url": "",
        "score": 0.8731
      }
    ]
  }
}
```

| Mode | What `data` holds, besides `rag_id`, `idioma` and `modo` |
| --- | --- |
| `fragmentos` | `fragmentos`: each with `texto`, `fuente_id`, `fuente`, `url` and `score`. Data from a live API comes with `score: null` and `en_vivo: true` |
| `llm` | `modelo`, `respuesta` and `fuentes` (the names of the sources used) |
| `mixto` | `modelo`, `respuesta` and `fragmentos` |

## Connect an agent over MCP

Every RAG is its own MCP server (streamable HTTP, stateless, answers in JSON) at `https://api.ardumaker.com/api/v1/rags/mcp/<RAG_ID>/`. Connect with the key in the `Authorization` header; a public RAG does not ask for it. An agent's key must have the `mcp` or `ambos` channel.

### Claude Code

```bash
claude mcp add --transport http mi-rag \
  https://api.ardumaker.com/api/v1/rags/mcp/<RAG_ID>/ \
  --header "Authorization: rgk_..."
```

### Cursor, `.mcp.json` and other clients with a JSON config

```json
{
  "mcpServers": {
    "mi-rag": {
      "type": "http",
      "url": "https://api.ardumaker.com/api/v1/rags/mcp/<RAG_ID>/",
      "headers": {
        "Authorization": "rgk_..."
      }
    }
  }
}
```

For a public RAG, drop `headers`. The panel builds these same examples, with the ID filled in, in **Access → How to connect an agent**.

| Tool | Parameters | What it does |
| --- | --- | --- |
| `consultar_rag` | `pregunta` (required), `modo`, `modelo`, `top_k` | The same as the HTTP API: fragments, a written answer or both |
| `listar_fuentes_rag` | None | The RAG's name, language and state, and its sources (except failed ones) with their type and state |

### Try it by hand with JSON-RPC

Each `POST` carries one JSON-RPC 2.0 message or a batch of up to 20: `initialize`, `ping`, `tools/list` and `tools/call`. There is no session and no SSE stream: `GET` and `DELETE` answer 405, and a notification gets 202 with no body.

```bash
curl -X POST https://api.ardumaker.com/api/v1/rags/mcp/<RAG_ID>/ \
  -H "Authorization: rgk_..." \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
```

```bash
curl -X POST https://api.ardumaker.com/api/v1/rags/mcp/<RAG_ID>/ \
  -H "Authorization: rgk_..." \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "consultar_rag",
      "arguments": {"pregunta": "What is the refund policy?", "modo": "fragmentos", "top_k": 3}
    }
  }'
```

The `tools/call` result comes in `result.content[0].text`, as JSON in text. Fragments are third-party data, never instructions for the agent.

## Plan and limits

| What | Value |
| --- | --- |
| Plan | **Gratis** (free): 0 €, no size cap and no daily query cap while the service is in launch |
| AI | Embeddings, transcriptions, translations and `llm` or `mixto` answers are paid with the company's Router IA key |
| Queries | Up to 30 per minute per IP and per RAG, on the HTTP API and on MCP |
| Files | Up to 90 MB each; no photos or videos |
| Question and `top_k` | Up to 4000 characters; 1 to 20 fragments |
| MCP batch | Up to 20 JSON-RPC messages per request |
| Websites | Depth 2 and 50 pages by default, configurable per RAG; re-read every 7 days |
| Live APIs | Up to 5 per query, with an 8-second timeout; one that does not answer is skipped |

Current plans are listed without authentication at `GET https://api.ardumaker.com/api/v1/rags/planes/`.

## Diagram

**A query**

```text
Your agent (HTTP API or MCP, key in Authorization)
  ↓
ArduMaker (checks the RAG, the key, the channel and the rate)
  ↓
Vector search (the top_k closest fragments, plus the live APIs)
  ↓
OpenRouter model (only in llm and mixto: writes the answer)
```

What the AI costs comes from the company's Router IA key.

## Expected result

- With the RAG **processed**, a query in `fragmentos` mode returns the passages with their source and score; the agent writes the answer.
- In `llm` and `mixto`, `respuesta` holds the text written in the RAG's language by the chosen model.
- Check it from **Try it** in the panel, or over MCP with `tools/list`: `consultar_rag` and `listar_fuentes_rag` must show up.
- **Information** shows the plan, today's queries, the size and the sources.

## Errors and troubleshooting

| Response | Cause | What to do |
| --- | --- | --- |
| 401 `falta_key` | Limited RAG without the `Authorization` header | Send the general key or an agent's key |
| 403 `key_invalida` | The key is not from this RAG, was rotated or was revoked | Check the key or create a new one |
| 403 `canal_no_autorizado` | The agent's key lacks that channel (for example, only `api` and it comes in over MCP) | Authorize it with `mcp` or `ambos` |
| 404 `rag_no_encontrado` | The ID does not exist or the RAG was deleted | Copy the ID from **Access** |
| 402 `empresa_en_mora` | The company has pending payments | Settle the balance |
| 402 `clave_de_ia_rechazada` | OpenRouter rejected the Router IA key (for example, no balance) | Check the key in Router IA |
| 409 `sin_clave_de_ia` | The company has no active Router IA key | Add a payment method or balance; it retries on its own |
| 400 `falta_pregunta`, `pregunta_muy_larga`, `modo_invalido`, `falta_modelo` | Incomplete or invalid request | Send `pregunta` (up to 4000 characters) and, in `llm` or `mixto`, `modelo` |
| 429 `limite_por_minuto` | More than 30 queries in one minute from the same IP to the same RAG | Wait for the next minute |
| 429 `limite_diario` | The plan's daily cap was reached (the free plan has none) | Wait for the next day |
| 424 `qdrant_caido`, `openrouter_caido`, `openrouter_error` | Vector search or OpenRouter did not answer, or OpenRouter returned an error (for example, a `modelo` that does not exist) | Check the model id and retry |
| 413 `archivo_muy_grande`, 415 `tipo_no_aceptado` | When loading: a file over 90 MB, or a photo or a video | Split the file or convert it to an accepted format |

Every HTTP API response has `success`, `menssage` and `data`, and on an error, `tipo` with the code in the first column. Over MCP, with no key or an invalid one, the response carries the same HTTP code and a JSON-RPC error `-32001`; an error inside a tool comes back in `result` with `isError: true`.

## MCP access

A RAG is used over MCP in two ways: with the RAG's own MCP server (see “Connect an agent over MCP”, with its key, for any agent) or with the platform's MCP (profiles `/mcp` and `/mcp/infra`), which signs in with your ArduMaker user over OAuth and adds three read-only tools:

- `listar_rags` (`company_id`, `limit`, `offset`): the company's RAGs with their public ID, language, visibility and state.
- `ver_rag` (`company_id`, `rag_id`): settings, plan, sources by state and whether it has an AI key.
- `consultar_rag` (`company_id`, `rag_id`, `pregunta`, `modo`, `modelo`, `top_k`): asks like the **Try it** box; the result is flagged as untrusted content.

Creating RAGs, loading content and authorizing agents is done in the panel. Tool reference at [/mcp/docs](https://ardumaker.com/en/mcp/docs).

## Related features

- [Router IA](https://ardumaker.com/en/docs/router-ia/): OpenRouter keys in the company's name, with usage charged to the ArduMaker balance and automatic pause on negative balance.
- [AI keys](https://ardumaker.com/en/docs/claves-ia/): Create Router IA keys with a spending cap, a token shown only once, limits for new companies, revocation and reactivation.
- [MCP server](https://ardumaker.com/en/docs/servidor-mcp/): MCP server with OAuth and human approval so AI agents can operate ArduMaker, with profiles, safe retries and limits.
- [Search API](https://ardumaker.com/en/docs/search-api/): Web search API for apps and agents: search, extract, crawl, map and parallel requests, charged to the company balance.
