> ## Documentation Index
> Fetch the complete documentation index at: https://anam.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Base (RAG)

> Give Anam personas access to your documents, from preparing and uploading reference material to connecting search tools and testing answers.

Anam's knowledge base lets a persona search your documents during a conversation. This is called Retrieval-Augmented Generation (RAG): the language model retrieves relevant passages and uses them to answer the user's question.

## How it works

**1. Create folders and prepare documents**

Organize reference material into knowledge folders, called **groups** in the API. Choose files appropriate for the persona's audience, and keep facts with their conditions, exceptions, and sources.

**2. Upload and wait for processing**

Upload the files to a folder. Anam processes them into searchable passages. A document must reach `READY` before it can be searched; check processing status rather than relying on a fixed waiting time.

**3. Connect a knowledge tool**

Choose the folders a knowledge tool can search and attach it to your persona. Its description tells the language model when to use it.

**4. Search during a conversation**

When the persona calls the tool, it receives relevant passages from the selected folders and uses them to compose an answer. Test both the retrieved evidence and the answer before relying on the result.

## Quick links

| Task | Start here |
| - | - |
| Set up knowledge for the first time | [Set up your knowledge base](https://anam.ai/docs/personas/knowledge/setup.md) |
| Decide what a persona should access | [Set the knowledge scope](https://anam.ai/docs/personas/knowledge/setup.md#set-the-knowledge-scope) |
| Prepare manuals, policies, or FAQs | [Prepare documents](https://anam.ai/docs/personas/knowledge/preparing-documents.md) |
| Copy a starting document | [Document template](https://anam.ai/docs/personas/knowledge/document-template.md) |
| Upload files and check processing | [Upload documents](https://anam.ai/docs/personas/knowledge/uploading-documents.md) |
| Replace an outdated policy | [Replace an existing document](https://anam.ai/docs/personas/knowledge/uploading-documents.md#replace-an-existing-document) |
| Let a persona search your documents | [Connect knowledge tools](https://anam.ai/docs/personas/knowledge/tools.md) |
| Check or improve inaccurate answers | [Test your knowledge base](https://anam.ai/docs/personas/knowledge/testing.md) |
| Check an upload before release | [Upload checklist](https://anam.ai/docs/personas/knowledge/upload-checklist.md) |
| Create folders through the API | [Create knowledge group](https://anam.ai/docs/api-reference/knowledge/create-knowledge-group.md) |

## Prepare knowledge for your audience

A retrieved passage may appear without its surrounding pages. Give facts explicit subjects, such as the product, version, or region, and keep exceptions beside the claims they qualify. See [Prepare documents](https://anam.ai/docs/personas/knowledge/preparing-documents.md) for examples.

Knowledge tools search the folders you attach. Check all documents in those folders for the intended audience. Labels such as “internal only” inside a file do not restrict access; see [Set the knowledge scope](https://anam.ai/docs/personas/knowledge/setup.md#set-the-knowledge-scope).

Keep personality and behavior instructions in the [persona's prompt](https://anam.ai/docs/personas/llms/prompting-guide.md). Use knowledge documents for reference facts, policies, and procedures.

## Access and retention

Knowledge groups and documents belong to the organization that created them. Every API request is scoped to your organization, so a folder or document ID from one organization cannot be read by another.

Within your organization, a persona can search whichever folders its knowledge tools select — see [Set the knowledge scope](https://anam.ai/docs/personas/knowledge/setup.md#set-the-knowledge-scope) for choosing those deliberately.

The knowledge endpoints authenticate with your API key, which grants access to everything your organization owns, so call them only from your server and keep the key there. Browser code never calls these endpoints: it uses a session token, which authenticates a conversation with a persona rather than access to your documents. See [Authentication](https://anam.ai/docs/javascript-sdk/authentication.md).

> [!WARNING]
>
> [Zero Data Retention](https://anam.ai/docs/security/privacy.md) does not cover files uploaded to a knowledge base. Uploaded documents are stored so they can be searched, even for personas and sessions that have Zero Data Retention enabled.

## Troubleshooting

| Problem | Next step |
| - | - |
| Upload fails or processing does not complete | [Upload troubleshooting](https://anam.ai/docs/personas/knowledge/uploading-documents.md#troubleshooting) |
| Search returns nothing or the wrong source | [Inspect retrieved passages](https://anam.ai/docs/personas/knowledge/testing.md#inspect-retrieved-passages) |
| Answers omit exceptions or use old information | [Diagnose a failed check](https://anam.ai/docs/personas/knowledge/testing.md#diagnose-a-failed-check) |
| You need to check file support or storage limits | [Supported file types](https://anam.ai/docs/personas/knowledge/setup.md#supported-file-types) and [upload limits](https://anam.ai/docs/personas/knowledge/setup.md#upload-limits) |

## Next steps

> [card] [Set up your knowledge base](https://anam.ai/docs/personas/knowledge/setup.md)
>
> Create folders and choose the reference material your persona needs.

> [card] [RAG cookbook tutorial](https://anam.ai/cookbook/rag-knowledge-base)
>
> Follow a worked example of adding a knowledge base to an avatar agent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.