> ## 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.

# RAG Query • AI Agent SDK

> rag_query: Query knowledge using RAG pipeline with citations.

# rag\_query

<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.

Query knowledge using RAG pipeline with citations.

This is the recommended way to get answers with citations from an agent's knowledge.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def rag_query(question: str) -> 'RAGResult'
```

## Parameters

<ParamField query="question" type="str" required={true}>
  The question to answer \*\*kwargs: Additional arguments passed to RAG.query()
</ParamField>

### Returns

<ResponseField name="Returns" type="'RAGResult'">
  RAGResult with answer, citations, context\_used, and metadata
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    If no knowledge sources are 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=["doc.pdf"], rag_config={"include_citations": True})
    result = agent.rag_query("What is the main finding?")
    print(result.answer)
    for citation in result.citations:
        print(f"[{citation.id}] {citation.source}: {citation.text[:100]}")
```

## Uses

* `ValueError`
* `ImportError`
* `kwargs.setdefault`
* `query`

## Source

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

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="RAG Concept" icon="magnifying-glass" href="/docs/concepts/rag" />

  <Card title="RAG Overview" icon="database" href="/docs/rag/overview" />

  <Card title="Chunking Strategies" icon="scissors" href="/docs/rag/strategies/overview" />
</CardGroup>
