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

# retrieve • AI Agent SDK

> retrieve: Retrieve context from knowledge without LLM generation.

# retrieve

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Agent**](../classes/Agent) class in the [**agent**](../modules/agent) module.

Retrieve context from knowledge without LLM generation.

Returns a ContextPack that can be passed to chat\_with\_context().
This enables conditional retrieval - only retrieve when needed.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def retrieve(query: str) -> 'ContextPack'
```

## Parameters

<ParamField query="query" type="str" required={true}>
  Search query \*\*kwargs: Additional arguments (top\_k, rerank, etc.)
</ParamField>

### Returns

<ResponseField name="Returns" type="'ContextPack'">
  ContextPack with context string and citations (no LLM call)
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    If no knowledge is configured
  </Accordion>

  <Accordion title="ImportError">
    If RAG module is not available
  </Accordion>
</AccordionGroup>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agent = Agent(knowledge=["docs/"], retrieval_config={"citations": True})
    context = agent.retrieve("What are the key findings?")
    print(f"Found {len(context.citations)} sources")
    response = agent.chat_with_context("Summarize", context)
```

## Uses

* `ValueError`
* `ImportError`
* `kwargs.setdefault`
* `retrieve`

## Used By

* [`Agent.retrieve`](../functions/Agent-retrieve)
* [`AutoRagAgent.chat`](../functions/AutoRagAgent-chat)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L3060">
  `praisonaiagents/agent/agent.py` at line 3060
</Card>
