> For the complete documentation index, see [llms.txt](https://university.mindstudio.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.mindstudio.ai/additional-resources/self-hosted-ai-models-quickstart-tutorial.md).

# Self-Hosted AI Models (Quickstart Tutorial)

## Prerequisites

Before getting started, ensure you have the following installed on your machine:

* [Ollama](https://ollama.com/)
* [Ngrok (for macOS)](https://ngrok.com/downloads/mac-os?tab=download)

***

## Step-by-Step Instructions

#### **1. Start an Ngrok Tunnel**

Open a terminal window and run the following command to expose port `11434` to the internet:

```bash
ngrok http http://localhost:11434
```

> Copy the forwarding HTTPS URL Ngrok provides (e.g. `https://xxxx.ngrok.io`). You'll need this later.

***

#### **2. Pull and Serve the AI Model**

Open a second terminal window:

**a. Pull the `llama3.2` model:**

```bash
ollama pull llama3.2
```

**b. Serve the model with the proper environment variables:**

Replace the Ngrok URL below with your actual forwarding address from Step 1:

**On Mac / Linux:**

```bash
OLLAMA_HOST=0.0.0.0:11434 OLLAMA_ORIGINS="https://xxxx.ngrok.io/" ollama serve
```

**On Windows:**

First

```bash
$Env:OLLAMA_HOST   = "0.0.0.0:11434"
$Env:OLLAMA_ORIGINS = "https://xxxx.ngrok.io/" 
```

then

```
ollama serve
```

> This command makes your local Ollama instance accessible through the Ngrok tunnel.

***

#### **3. Add the Self-Hosted Model to MindStudio**

1. Go to [MindStudio Self-Hosted Models](https://app.mindstudio.ai/workspace/self-hosted-models)
2. Click **"Add Model"**
3. Use the following fields:
   * **API Name**: (Ex: `llama3.2` )
   * **Endpoint**: `https://xxxx.ngrok.io/v1` (replace `xxxx` with your actual Ngrok subdomain)

> Your self-hosted AI model is now ready to be used in any MindStudio AI Agent.

***

## Using the Model in an Agent

Once added, you can:

* Select your AI Model in the **Model Settings** tab when editing an AI Agent.
* Use it across workflows, prompts, and block-level overrides in your automation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://university.mindstudio.ai/additional-resources/self-hosted-ai-models-quickstart-tutorial.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
