# Chain

> **Class** in `langchain_classic`

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

Abstract base class for creating structured sequences of calls to components.

Chains should be used to encode a sequence of calls to components like
models, document retrievers, other chains, etc., and provide a simple interface
to this sequence.

## Signature

```python
Chain()
```

## Description

**The Chain interface makes it easy to create apps that are:**

- Stateful: add Memory to any Chain to give it state,
- Observable: pass Callbacks to a Chain to execute additional functionality,
    like logging, outside the main sequence of component calls,
- Composable: the Chain API is flexible enough that it is easy to combine
    Chains with other components, including other Chains.

**The main methods exposed by chains are:**

- `__call__`: Chains are callable. The `__call__` method is the primary way to
    execute a Chain. This takes inputs as a dictionary and returns a
    dictionary output.
- `run`: A convenience method that takes inputs as args/kwargs and returns the
    output as a string or object. This method can only be used for a subset of
    chains and cannot return as rich of an output as `__call__`.

## Extends

- `RunnableSerializable[dict[str, Any], dict[str, Any]]`
- `ABC`

## Properties

- `memory`
- `callbacks`
- `verbose`
- `tags`
- `metadata`
- `callback_manager`
- `model_config`
- `input_keys`
- `output_keys`

## Methods

- [`get_input_schema()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/get_input_schema)
- [`get_output_schema()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/get_output_schema)
- [`invoke()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/invoke)
- [`ainvoke()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/ainvoke)
- [`raise_callback_manager_deprecation()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/raise_callback_manager_deprecation)
- [`set_verbose()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/set_verbose)
- [`acall()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/acall)
- [`prep_outputs()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/prep_outputs)
- [`aprep_outputs()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/aprep_outputs)
- [`prep_inputs()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/prep_inputs)
- [`aprep_inputs()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/aprep_inputs)
- [`run()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/run)
- [`arun()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/arun)
- [`dict()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/dict)
- [`save()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/save)
- [`apply()`](https://reference.langchain.com/python/langchain-classic/chains/base/Chain/apply)

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/b302691ff9ad841804e93e5addbdc53b6974473b/libs/langchain/langchain_classic/chains/base.py#L52)