# Retrieval Augmented Generation (RAG)

> Guide on using Cohere's Retrieval Augmented Generation (RAG) capabilities such as document grounding and citations.

Retrieval Augmented Generation (RAG) is a method for generating text using additional information fetched from an external data source, which can greatly increase the accuracy of the response. When used in conjunction with [Command](https://docs.cohere.com/docs/models#command) family of models, the [Chat API](https://docs.cohere.com/reference/chat) makes it easy to generate text that is grounded on supplementary documents, thus minimizing hallucinations.

## A quick example

To call the Chat API with RAG, pass the following parameters as a minimum:

* `model` for the model ID
* `messages` for the user's query.
* `documents` for defining the documents to be used as the context for the response.

The code snippet below, for example, will produce a grounded answer to `"Where do the tallest penguins live?"`, along with inline citations based on the provided documents.

<Tabs>
  <Tab title="Cohere platform">
    ```python PYTHON
    # ! pip install -U cohere
    import cohere

    co = cohere.ClientV2(
        "COHERE_API_KEY"
    )  # Get your free API key here: https://dashboard.cohere.com/api-keys
    ```
  </Tab>

  <Tab title="Private deployment">
    ```python PYTHON
    # ! pip install -U cohere
    import cohere

    co = cohere.ClientV2(
        api_key="",  # Leave this blank
        base_url="<YOUR_DEPLOYMENT_URL>",
    )
    ```
  </Tab>
</Tabs>

```python PYTHON