# create_retrieval_chain

> **Function** in `langchain_classic`

📖 [View in docs](https://reference.langchain.com/python/langchain-classic/chains/retrieval/create_retrieval_chain)

Create retrieval chain that retrieves documents and then passes them on.

## Signature

```python
create_retrieval_chain(
    retriever: BaseRetriever | Runnable[dict, RetrieverOutput],
    combine_docs_chain: Runnable[dict[str, Any], str],
) -> Runnable
```

## Description

**Example:**

```python
# pip install -U langchain langchain-openai

from langchain_openai import ChatOpenAI
from langchain_classic.chains.combine_documents import (
    create_stuff_documents_chain,
)
from langchain_classic.chains import create_retrieval_chain
from langchain_classic import hub

retrieval_qa_chat_prompt = hub.pull("langchain-ai/retrieval-qa-chat")
model = ChatOpenAI()
retriever = ...
combine_docs_chain = create_stuff_documents_chain(
    model, retrieval_qa_chat_prompt
)
retrieval_chain = create_retrieval_chain(retriever, combine_docs_chain)

retrieval_chain.invoke({"input": "..."})
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `retriever` | `BaseRetriever \| Runnable[dict, RetrieverOutput]` | Yes | Retriever-like object that returns list of documents. Should either be a subclass of BaseRetriever or a Runnable that returns a list of documents. If a subclass of BaseRetriever, then it is expected that an `input` key be passed in - this is what is will be used to pass into the retriever. If this is NOT a subclass of BaseRetriever, then all the inputs will be passed into this runnable, meaning that runnable should take a dictionary as input. |
| `combine_docs_chain` | `Runnable[dict[str, Any], str]` | Yes | Runnable that takes inputs and produces a string output. The inputs to this will be any original inputs to this chain, a new context key with the retrieved documents, and chat_history (if not present in the inputs) with a value of `[]` (to easily enable conversational retrieval. |

## Returns

`Runnable`

An LCEL Runnable. The Runnable return is a dictionary containing at the very

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/fb6ab993a73180538f6cca876b3c85d46c08845f/libs/langchain/langchain_classic/chains/retrieval.py#L12)