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

# Ollama

> [Ollama](https://ollama.com/) allows you to run open-source large language models,
> such as [gpt-oss](https://ollama.com/library/gpt-oss), locally.
>
> `Ollama` bundles model weights, configuration, and data into a single package, defined by a Modelfile.
> It optimizes setup and configuration details, including GPU usage.
> For a complete list of supported models and model variants, see the [Ollama model library](https://ollama.ai/library).

See [this guide](/oss/python/how-to/local_llms#ollama) for more details
on how to use `ollama` with LangChain.

## Installation and Setup

### Ollama installation

Follow [these instructions](https://github.com/ollama/ollama?tab=readme-ov-file#ollama)
to set up and run a local Ollama instance.

Ollama will start as a background service automatically, if this is disabled, run:

```bash theme={null}
# export OLLAMA_HOST=127.0.0.1 # environment variable to set ollama host
# export OLLAMA_PORT=11434 # environment variable to set the ollama port
ollama serve
```

After starting ollama, run `ollama pull <name-of-model>` to download a model from the [Ollama model library](https://ollama.ai/library):

```bash theme={null}
ollama pull gpt-oss:20b
```

* This will download the default tagged version of the model. Typically, the default points to the latest, smallest sized-parameter model.
* To view all pulled (downloaded) models, use `ollama list`

We're now ready to install the `langchain-ollama` partner package and run a model.

### Ollama LangChain partner package install

Install the integration package with:

<CodeGroup>
  ```bash pip theme={null}
  pip install langchain-ollama
  ```

  ```bash uv theme={null}
  uv add langchain-ollama
  ```
</CodeGroup>

## LLM

```python theme={null}
from langchain_ollama.llms import OllamaLLM
```

See the notebook example [here](/oss/python/integrations/llms/ollama).

## Chat Models

### Chat Ollama

```python theme={null}
from langchain_ollama.chat_models import ChatOllama
```

See the notebook example [here](/oss/python/integrations/chat/ollama).

### Ollama tool calling

[Ollama tool calling](https://ollama.com/blog/tool-support) uses the
OpenAI compatible web server specification, and can be used with
the default `BaseChatModel.bind_tools()` methods
as described [here](/oss/python/langchain/tools/).
Make sure to select an ollama model that supports [tool calling](https://ollama.com/search?\&c=tools).

## Embedding models

```python theme={null}
from langchain_community.embeddings import OllamaEmbeddings
```

See the notebook example [here](/oss/python/integrations/text_embedding/ollama).
