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

# Basic RAG

> Build a knowledge base and ground an agent in documents.

Create a knowledge base, add documents, and use it with an agent.

<Steps>
  <Step title="Create the agent">
    ```python basic_rag.py theme={null}
    import asyncio
    from definable.agent import Agent
    from definable.knowledge import Knowledge
    from definable.vectordb import InMemoryVectorDB

    # Create knowledge base
    knowledge = Knowledge(vector_db=InMemoryVectorDB())

    # Add documents
    knowledge.add("Definable is a Python framework for building AI agents.")
    knowledge.add("It supports 10 LLM providers including OpenAI, Anthropic, and Google.")
    knowledge.add("Agents can use tools, knowledge, memory, middleware, and tracing.")
    knowledge.add("The @tool decorator converts Python functions into agent-callable tools.")

    # Create agent with knowledge
    agent = Agent(
        model="gpt-4o",
        knowledge=knowledge,
        instructions="Answer questions using the provided knowledge base. Cite specific facts.",
    )

    async def main():
        output = await agent.arun("What LLM providers does Definable support?")
        print(output.content)

    asyncio.run(main())
    ```
  </Step>

  <Step title="Install and run">
    <Snippet file="install-definable.mdx" />

    ```bash theme={null}
    python basic_rag.py
    ```
  </Step>
</Steps>

## Path Shorthand

Load an entire directory of documents:

```python theme={null}
agent = Agent(model="gpt-4o", knowledge="./docs/")
```

This auto-configures InMemoryVectorDB + OpenAIEmbedder + RecursiveChunker and recursively loads all supported files.
