# Add Ollama endpoint

## Prerequisite

* Ollama version: 0.1.19 or later
* Running at least one model under Ollama

## Add endpoint

Go to **MindMac** -> **Settings...** -> **Account** or press <mark style="color:purple;">**⌘**</mark> + <mark style="color:purple;">**,**</mark> to open Account Setting.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FvgrtwggGVvZrnOEnkv7g%2Faddapikey1.jpg?alt=media&#x26;token=4e6137d8-dc53-40b4-afbf-da0691aa3bd4" alt=""><figcaption></figcaption></figure>

* Select **Ollama** as provider
* Enter a name
* If you don't change any Ollama configuration, just use <http://localhost:11434/api/chat> as URL
* Enter a random text in API Key text area
* Click **Save** to finish

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FDSD7Y37odIvBxLNNEXFF%2Follama.jpg?alt=media&#x26;token=6cfe1408-0486-4c48-89bf-7dd8528f1111" alt=""><figcaption></figcaption></figure>

***

## Customize Context Length (Optional)

Currently Ollama does not provide exact context length for each model, so if you want to control **max tokens** (or context length) parameter,  you might need to enter that value manually for every Ollama model. Follow below steps to do so.

Go to **MindMac** -> **Settings...** -> **Account** or press <mark style="color:purple;">**⌘**</mark> + <mark style="color:purple;">**,**</mark> to open Account Setting.

Click on the brain icon to show Ollama model list.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FGmIj5eJ8vpBA7Y6DRTeZ%2Follama-update-context-length1.jpg?alt=media&#x26;token=177776ca-387c-4e79-a9c2-d123e361b17f" alt=""><figcaption></figcaption></figure>

Click on the edit button.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FBLF18DUxC1EP6v6iULDp%2Follama-update-context-length2.jpg?alt=media&#x26;token=0683e7db-f4b2-44b6-a75f-94b1ccf93966" alt=""><figcaption></figcaption></figure>

Enter max tokens value for that model and click **Save** to finish.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FBASqWpNcVr2xMnSTun3L%2Follama-update-context-length3.jpg?alt=media&#x26;token=826e79dd-2095-4d03-a7c8-ace6fb5cd2f7" alt=""><figcaption></figcaption></figure>

To get max tokens value for each model, you can find in configuration file (**config.json** for example) of that model on Hugging Face. For instance, with the model [Mixtral-8x7B-Instruct-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1) , you can go to <https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1/blob/main/config.json> and grab the value **max\_position\_embeddings** as its context length. Kindly be aware that there is no standard specifying which key determines the context length of a model in the model configuration file.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2Fnu6IEOodDQuVw1vGT1sL%2Fhowtogetcontextlength1.jpg?alt=media&#x26;token=c6ffa15b-5259-451c-b750-a437f4d699c6" alt=""><figcaption></figcaption></figure>
