> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-devupd-1765394015-eccef47.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cohere

<Warning>
  **You are currently on a page documenting the use of Cohere models as text completion models. Many popular Cohere models are [chat completion models](/oss/python/langchain/models).**

  You may be looking for [this page instead](/oss/python/integrations/chat/cohere/).
</Warning>

> [Cohere](https://cohere.ai/about) is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.

Head to the [API reference](https://python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html) for detailed documentation of all attributes and methods.

## Overview

### Integration details

| Class                                                                                                           | Package                                                                                | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/llms/cohere/) |                                               Downloads                                              |                                              Version                                              |
| :-------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------- | :---: | :----------: | :-------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
| [Cohere](https://python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html) | [langchain-community](https://python.langchain.com/api_reference/community/index.html) |   ❌   |     beta     |                                   ✅                                   | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain_community?style=flat-square\&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain_community?style=flat-square\&label=%20) |

## Setup

The integration lives in the `langchain-community` package. We also need to install the `cohere` package itself. We can install these with:

### Credentials

We'll need to get a [Cohere API key](https://cohere.com/) and set the `COHERE_API_KEY` environment variable:

```python theme={null}
import getpass
import os

if "COHERE_API_KEY" not in os.environ:
    os.environ["COHERE_API_KEY"] = getpass.getpass()
```

### Installation

```python theme={null}
pip install -U langchain-community langchain-cohere
```

It's also helpful (but not needed) to set up [LangSmith](https://smith.langchain.com/) for best-in-class observability

```python theme={null}
os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()
```

## Invocation

Cohere supports all [LLM](/oss/python/langchain/models) functionality:

```python theme={null}
from langchain_cohere import Cohere
from langchain.messages import HumanMessage
```

```python theme={null}
model = Cohere(max_tokens=256, temperature=0.75)
```

```python theme={null}
message = "Knock knock"
model.invoke(message)
```

```output theme={null}
" Who's there?"
```

```python theme={null}
await model.ainvoke(message)
```

```output theme={null}
" Who's there?"
```

```python theme={null}
for chunk in model.stream(message):
    print(chunk, end="", flush=True)
```

```output theme={null}
 Who's there?
```

```python theme={null}
model.batch([message])
```

```output theme={null}
[" Who's there?"]
```

***

## API reference

For detailed documentation of all `Cohere` llm features and configurations head to the API reference: [python.langchain.com/api\_reference/community/llms/langchain\_community.llms.cohere.Cohere.html](https://python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html)

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/llms/cohere.mdx)
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
