# RAG knowledge bases

Source: [RAG knowledge bases](<https://docs.gptunnel.ru/en/rag/>)

<a id="_top"></a>
> **Note: API key access**
>
> You need an API key to send requests. See [Quick start](<https://docs.gptunnel.ru/en/>)

A RAG knowledge base stores documents that an [assistant](<https://docs.gptunnel.ru/en/api/assistants/about/>) uses to answer questions. Uploaded files are automatically split into chunks and indexed so the assistant can retrieve relevant passages.

Create knowledge bases in the GPTunneL interface. Use the API to list them and to add or delete files.

<a id="base-url"></a>
## Base URL

```plaintext
https://gptunnel.ru/v1/database
```

 <a id="эндпоинты-раздела"></a>
 
<a id="endpoints"></a>
## Endpoints

| Method | Endpoint | Behavior |
| --- | --- | --- |
| `GET` | [`/v1/database/list`](<https://docs.gptunnel.ru/en/rag/list/>) | API Key Owner Databases |
| `GET` | [`/v1/database/file/list`](<https://docs.gptunnel.ru/en/rag/file-list/>) | Files in a database or file information |
| `POST` | [`/v1/database/file/add`](<https://docs.gptunnel.ru/en/rag/file-add/>) | Upload File to Database |
| `POST` | [`/v1/database/file/delete`](<https://docs.gptunnel.ru/en/rag/file-delete/>) | Remove File from Base |

Start with the [list of knowledge bases](<https://docs.gptunnel.ru/en/rag/list/>). It provides the `databaseId` required by the file endpoints.

After uploading a file, save its `id` and pass it as `fileId` when you [check its status](<https://docs.gptunnel.ru/en/rag/file-list/>). The response is an array with one entry. Wait until its status is `ready`, then connect the knowledge base to the assistant and ask about a fact from the file. To verify retrieval after deleting the file, use a new chat. The old chat may still contain the answer in its history. See [delete a file](<https://docs.gptunnel.ru/en/rag/file-delete/>) for the conditions under which deletion unlinks the knowledge base from assistants and bots.
