Skip to main content

Overview

The Ollama provider connects to locally-running Ollama instances to use open-source models like Qwen, Llama, and others. It supports the full OpenAI-compatible API with tool calling. Source: crates/goose/src/providers/ollama.rs

Configuration

Environment Variables

string
default:"localhost"
Ollama server host (automatically adds port 11434 for localhost)
number
default:"600"
Request timeout in seconds
number
Override context window size (sets num_ctx option)

Setup

Supported Models

  • qwen3 (default) - Qwen 3 base model
  • qwen3-vl - Qwen 3 with vision capabilities
  • qwen3-coder:30b - 30B parameter coding model
  • qwen3-coder:480b-cloud - Large cloud-based coding model
  • llama3.3 - Meta’s Llama 3.3
  • codellama - Code-specialized Llama
  • mistral - Mistral models
  • gemma - Google’s Gemma
  • phi - Microsoft’s Phi models
Model Library: https://ollama.com/library

Usage

Basic Usage

Custom Configuration

Setting Context Window

Ollama allows configuring the context window size:
This sets the num_ctx parameter in Ollama options.

Advanced Features

Tool Calling

Ollama supports native tool calling for compatible models:

XML Tool Call Fallback

For models without native tool support, Ollama automatically falls back to XML-based tool calls:
The provider parses these and converts them to proper tool calls.

Chat Mode

Disable tools in chat-only mode:
In chat mode, tools are filtered out before sending to Ollama.

Vision Models

Use vision-capable models for image understanding:

Remote Ollama

Connect to Ollama running on another machine:

Port Handling

  • localhost defaults to port 11434
  • Remote hosts without explicit port: no default port
  • Explicit ports in URL are respected: http://host:8080

Implementation Details

Provider Metadata

API Format

Uses OpenAI-compatible chat completions format:
Endpoint: POST /v1/chat/completions

Context Window Configuration

No Authentication

Ollama doesn’t require authentication:

Streaming

Ollama supports standard SSE streaming with a custom parser that handles XML tool calls:

Fetching Available Models

Example response:

Error Handling

Custom Provider Configuration

Create from declarative config:

Performance Tips

1. Adjust Context Window

Smaller context = faster inference:

2. Use Quantized Models

Smaller quantized models are faster:

3. GPU Acceleration

Ollama automatically uses GPU when available. Check with:

4. Keep Models Loaded

Models stay in memory after first use. For faster subsequent requests:

Troubleshooting

Ollama Not Running

Model Not Found

Out of Memory

Reduce context window or use smaller model:

See Also