# Ollama

> Run and interact with local Ollama LLM models. Use when agents need to run local AI models for text generation, chat completions, embeddings, or model management. Supports listing available models, pulling/downloading new models, generating text completions, chat completions (single and bulk), generating embeddings, and inspecting model details. No API key required - connects to local Ollama instance (default http://localhost:11434). Set OLLAMA_HOST env var to override.

- Skill: `buzzmatic/ollama` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add buzzmatic/ollama`
- Raw SKILL.md: https://api.skillmd.com/api/skills/buzzmatic/ollama/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: Buzzmatic (https://skillmd.com/u/buzzmatic)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/buzzmatic/ollama

---


# Ollama Local LLM Skill

Interact with locally-running Ollama models via a single unified script.

## Prerequisites

Ollama must be running locally. Start with `ollama serve` or via the Ollama desktop app. Default endpoint: `http://localhost:11434`. Override with `OLLAMA_HOST` env var.

## Quick Start

All commands use the same script with subcommands:

```bash
python skills/ollama/scripts/ollama_api.py [--timeout 300] <command> [options]
```

Outputs are written to `output/` under the current working directory.

## Commands

### List Models

```bash
python skills/ollama/scripts/ollama_api.py list
```

### Pull a Model

```bash
python skills/ollama/scripts/ollama_api.py pull --model qwen3:8b
python skills/ollama/scripts/ollama_api.py pull --model llama3.2
```

### Show Model Info

```bash
python skills/ollama/scripts/ollama_api.py show --model qwen3:8b
```

### Generate (Text Completion)

```bash
python skills/ollama/scripts/ollama_api.py generate \
  --model qwen3:8b \
  --prompt "Explain backlinks in SEO" \
  --system "You are an SEO expert" \
  --temperature 0.7 \
  --num-predict 500
```

From file:
```bash
python skills/ollama/scripts/ollama_api.py generate \
  --model qwen3:8b \
  --prompt-file data/processed/prompt.txt
```

### Chat Completion

```bash
python skills/ollama/scripts/ollama_api.py chat \
  --model qwen3:8b \
  --messages '[{"role":"user","content":"What is SEO?"}]' \
  --temperature 0.7
```

With system message:
```bash
python skills/ollama/scripts/ollama_api.py chat \
  --model qwen3:8b \
  --messages '[{"role":"system","content":"You are an SEO expert"},{"role":"user","content":"Explain keyword clustering"}]'
```

From file:
```bash
python skills/ollama/scripts/ollama_api.py chat \
  --model qwen3:8b \
  --messages-file data/processed/conversation.json
```

With structured JSON output:
```bash
python skills/ollama/scripts/ollama_api.py chat \
  --model qwen3:8b \
  --messages '[{"role":"user","content":"List 3 SEO tools"}]' \
  --format json
```

### Bulk Chat (JSONL)

Process multiple requests from a JSONL file:

```bash
python skills/ollama/scripts/ollama_api.py chat-bulk \
  --model qwen3:8b \
  --messages-file prompts.jsonl \
  --rate-limit 30
```

**JSONL format:**
```json
{"messages":[{"role":"user","content":"Analyze: seo tools"}],"id":"kw_001"}
{"messages":[{"role":"user","content":"Analyze: backlinks"}],"id":"kw_002"}
```

### Embeddings

Requires an embedding model (e.g. `nomic-embed-text`, `mxbai-embed-large`). Pull one first:
```bash
python skills/ollama/scripts/ollama_api.py pull --model nomic-embed-text
```

Then generate embeddings:
```bash
python skills/ollama/scripts/ollama_api.py embed \
  --model nomic-embed-text \
  --input "What is search engine optimization?"
```

From file (one text per line):
```bash
python skills/ollama/scripts/ollama_api.py embed \
  --model nomic-embed-text \
  --input-file texts.txt
```

### Delete a Model

```bash
python skills/ollama/scripts/ollama_api.py delete --model llama3.2
```

## Generation Options

Available for `generate`, `chat`, and `chat-bulk`:

| Flag | Description |
|------|-------------|
| `--temperature` | Sampling temperature (0-2) |
| `--top-p` | Nucleus sampling |
| `--top-k` | Top-k sampling |
| `--num-predict` | Max tokens to generate |
| `--num-ctx` | Context window size |
| `--seed` | Random seed for reproducibility |
| `--repeat-penalty` | Repetition penalty |
| `--stop` | Comma-separated stop sequences |

## Output Format

All commands return JSON to stdout:

```json
{
  "output_files": ["output/ollama_generate_...json"],
  "summary": "Generated 150 tokens in 2.3s with qwen3:8b",
  "response": "First 500 chars of response...",
  "stats": { "model": "qwen3:8b", "eval_count": 150, "total_duration_s": 2.3 }
}
```

## Error Handling

If Ollama is not running, the script exits with code 1 and prints:
```json
{"error": "Cannot connect to Ollama. Is it running? Start with: ollama serve"}
```

