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

# AI21 labs integrations

> Integrate with AI21 labs using LangChain Python.

> [AI21 Labs](https://www.ai21.com/about) is a company specializing in Natural
> Language Processing (NLP), which develops AI systems
> that can understand and generate natural language.

This page covers how to use the `AI21` ecosystem within `LangChain`.

## Installation and setup

* Get an AI21 api key and set it as an environment variable (`AI21_API_KEY`)
* Install the Python package:

```bash pip theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pip install langchain-ai21
```

```bash uv theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
uv add langchain-ai21
```

## Chat models

### AI21 chat

See the [AI21 docs](https://docs.ai21.com/).

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_ai21 import ChatAI21
```

## Deprecated features

:::caution The following features are deprecated.
:::

### AI21 LLM

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_ai21 import AI21LLM
```

### AI21 contextual answer

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_ai21 import AI21ContextualAnswers
```

## Text splitters

### AI21 Semantic text splitter

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_ai21 import AI21SemanticTextSplitter
```

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/ai21.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
