> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Traditional RAG with LanceDB

> Retrieve from LanceDB for a string input and append references before the first model call.

For a string-input run, set `add_knowledge_to_context=True` to retrieve before the first model call.

```python traditional_rag_lancedb.py theme={null}
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.vectordb.lancedb import LanceDb, SearchType

knowledge = Knowledge(
    vector_db=LanceDb(
        table_name="recipes",
        uri="tmp/lancedb",
        search_type=SearchType.vector,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
)

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    knowledge=knowledge,
    add_knowledge_to_context=True,
    search_knowledge=False,
    markdown=True,
)

if __name__ == "__main__":
    knowledge.insert(
        name="Thai Recipes",
        url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
    )
    agent.print_response(
        "How do I make chicken and galangal in coconut milk soup?",
        stream=True,
    )
```

## Run the Agent

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno lancedb openai pypdf
```

**2. Export the API key**

```bash theme={null}
export OPENAI_API_KEY=your_openai_api_key_here
```

**3. Run the agent**

```bash theme={null}
python traditional_rag_lancedb.py
```

## How It Works

1. `add_knowledge_to_context=True` searches with the run's string input.
2. Returned documents are appended to the user message inside a `<references>` block.
3. `search_knowledge=False` removes the model-callable search tool.

## Next Steps

| Task | Guide |
| - | - |
| Let the model choose when to search | [Agentic RAG with LanceDB](https://agno-v2.mintlify.site/knowledge/agents/agentic-rag-lancedb.md) |
| Change the retrieval signal | [Search and Retrieval](https://agno-v2.mintlify.site/knowledge/concepts/search-and-retrieval/overview.md) |
| Apply metadata filters | [Filtering](https://agno-v2.mintlify.site/knowledge/concepts/filters/overview.md) |


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