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

# Ollama

> Run workflow steps on models on your own Ollama server, reached through a tunnel with access control in front.

Add your own Ollama server to run workflow steps on open models on your hardware. See [Your own AI providers](https://docs.spojit.com/ai-providers/overview.md) for how providers work.

Spojit runs in the cloud, so it reaches your server over the internet. Ollama has no sign-in of its own: anyone who can reach its address can use it. Put it behind a tunnel that requires a token, as below, and never open port 11434 to the internet directly.

## 1. Run Ollama and pull a model

Install Ollama from [ollama.com](https://ollama.com/download), then pull the models you want:

```bash theme={null}
ollama pull qwen3:32b
```

Agent steps need a model that supports tools. On [ollama.com/search](https://ollama.com/search?c=tools), the **tools** filter lists them.

## 2. Give it a public https address

Choose one of the two tunnels below. Both give you an https address and keep your server's port closed.

> [tab] ngrok
>
> 1. Install the [ngrok agent](https://ngrok.com/download) and sign in.
>
> 2. Choose a long random token, for example from `openssl rand -hex 32`.
>
> 3. Save this policy as `ollama.yaml`. It turns away any request without your token, and sets the `Host` header that Ollama expects:
>
>    ```yaml theme={null}
>    on_http_request:
>      - expressions:
>          - "!hasReqHeader('Authorization') || getReqHeader('Authorization')[0] != 'Bearer YOUR_TOKEN'"
>        actions:
>          - type: deny
>            config:
>              status_code: 401
>      - actions:
>          - type: add-headers
>            config:
>              headers:
>                host: localhost
>    ```
>
> 4. Start the tunnel:
>
>    ```bash theme={null}
>    ngrok http 11434 --traffic-policy-file ollama.yaml
>    ```
>
> In Spojit, the address is the ngrok address, and the **API key** is your token. Spojit sends it as `Authorization: Bearer <token>`, which the policy checks. See [ngrok's Ollama guide](https://ngrok.com/docs/universal-gateway/examples/ollama) for more options.

> [tab] Cloudflare Tunnel
>
> 1. In Cloudflare, create a tunnel for a hostname on your domain, for example `ollama.example.com`, pointing at `http://localhost:11434`. Set the **HTTP Host Header** to `localhost:11434` (with `cloudflared` on the command line, `--http-host-header localhost:11434`).
> 2. In **Zero Trust → Access**, add a self-hosted application for that hostname.
> 3. Create a [service token](https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/) and give the application a policy with the **Service Auth** action that allows that token.
>
> In Spojit, the address is your hostname. Leave the **API key** empty and add two headers: `CF-Access-Client-Id` and `CF-Access-Client-Secret`, with the service token's values.

Check the tunnel before adding it. A request with your token or headers should list your models, and one without should be refused:

```bash theme={null}
curl https://your-address/v1/models -H "Authorization: Bearer YOUR_TOKEN"
```

## 3. Add it in Spojit

1. Open **Settings → AI providers** and select **Add provider**.
2. Choose **Ollama** and give it a name.
3. Enter the tunnel's address, for example `https://ollama.example.com`. Spojit adds `/v1` itself.
4. Enter the key or the headers from step 2.
5. Select **Add provider**. Spojit checks that it can list your models.

## 4. Add models

Add each model by its Ollama name with its tag, as `ollama list` shows it, for example `qwen3:32b`.

## Keep it running

* The computer running Ollama has to be on, with the tunnel running, whenever a workflow uses it. A step on a server that doesn't answer fails with "Ollama didn't answer", with the name you gave the provider.
* Large models on modest hardware are slow, and steps that wait longer use more execution minutes. A model loads into memory on its first request, so the first step after a pause is the slowest. Ollama's `OLLAMA_KEEP_ALIVE` setting keeps it loaded longer.
* Requests from workflow steps can be long. Ollama's default context window is small; raise it with `OLLAMA_CONTEXT_LENGTH` for agent steps that read a lot.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.