ollama
Run LLMs locally with Ollama. Use when a user asks to run AI models locally, self-host a language model, use LLaMA or Mistral on their machine, run offline AI, build a local chatbot, avoid sending data to cloud AI providers, generate text without API costs, fine-tune or customize local models, or set up a private AI inference server. Covers model management, API usage, Modelfile customization, GPU acceleration, and integration with LangChain and other frameworks.
Best use case
ollama is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Run LLMs locally with Ollama. Use when a user asks to run AI models locally, self-host a language model, use LLaMA or Mistral on their machine, run offline AI, build a local chatbot, avoid sending data to cloud AI providers, generate text without API costs, fine-tune or customize local models, or set up a private AI inference server. Covers model management, API usage, Modelfile customization, GPU acceleration, and integration with LangChain and other frameworks.
Teams using ollama should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ollama/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ollama Compares
| Feature / Agent | ollama | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Run LLMs locally with Ollama. Use when a user asks to run AI models locally, self-host a language model, use LLaMA or Mistral on their machine, run offline AI, build a local chatbot, avoid sending data to cloud AI providers, generate text without API costs, fine-tune or customize local models, or set up a private AI inference server. Covers model management, API usage, Modelfile customization, GPU acceleration, and integration with LangChain and other frameworks.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Ollama
## Overview
Ollama makes running large language models locally as simple as `ollama run llama3`. No cloud API, no API keys, no per-token costs — models run entirely on your hardware. It supports LLaMA 3, Mistral, Phi, Gemma, CodeLlama, and dozens of other open models. This skill covers model management, API integration, custom model configuration, GPU setup, and building applications with local LLMs.
## Instructions
### Step 1: Installation
```bash
# Linux
curl -fsSL https://ollama.com/install.sh | sh
# macOS
brew install ollama
# Docker
docker run -d --gpus all -v ollama_data:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
# Verify
ollama --version
```
### Step 2: Download and Run Models
```bash
# Download and start chatting
ollama run llama3.1 # Meta LLaMA 3.1 8B
ollama run mistral # Mistral 7B
ollama run codellama # Code-focused LLaMA
ollama run phi3 # Microsoft Phi-3 (small, fast)
ollama run gemma2 # Google Gemma 2
ollama run llama3.1:70b # Larger 70B model (needs ~40GB RAM)
ollama run deepseek-r1:8b # DeepSeek R1 reasoning model
# List downloaded models
ollama list
# Remove a model
ollama rm mistral
# Model info
ollama show llama3.1
```
### Step 3: REST API
Ollama exposes an OpenAI-compatible API at `http://localhost:11434`.
```bash
# Generate completion
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt": "Explain recursion in one paragraph.",
"stream": false
}'
# Chat completion (OpenAI-compatible)
curl http://localhost:11434/v1/chat/completions -d '{
"model": "llama3.1",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is a closure in JavaScript?"}
]
}'
# Generate embeddings
curl http://localhost:11434/api/embed -d '{
"model": "llama3.1",
"input": "How to deploy a Node.js app"
}'
```
### Step 4: Node.js Integration
```typescript
// lib/local-ai.ts — Use Ollama from Node.js via OpenAI-compatible API
// Any OpenAI SDK works — just change the base URL
import OpenAI from 'openai'
const ollama = new OpenAI({
baseURL: 'http://localhost:11434/v1',
apiKey: 'ollama', // required by SDK but not used by Ollama
})
// Chat completion (same API as OpenAI)
const response = await ollama.chat.completions.create({
model: 'llama3.1',
messages: [
{ role: 'system', content: 'You are a code review assistant.' },
{ role: 'user', content: 'Review this function:\n\nfunction add(a, b) { return a + b; }' },
],
temperature: 0.3,
})
console.log(response.choices[0].message.content)
// Streaming
const stream = await ollama.chat.completions.create({
model: 'llama3.1',
messages: [{ role: 'user', content: 'Write a haiku about coding.' }],
stream: true,
})
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '')
}
```
### Step 5: Python Integration
```python
# local_chat.py — Use Ollama from Python
import ollama
# Simple generation
response = ollama.chat(
model='llama3.1',
messages=[
{'role': 'system', 'content': 'You are a data analysis expert.'},
{'role': 'user', 'content': 'Explain the difference between L1 and L2 regularization.'},
],
)
print(response['message']['content'])
# Streaming
stream = ollama.chat(
model='llama3.1',
messages=[{'role': 'user', 'content': 'Explain MapReduce.'}],
stream=True,
)
for chunk in stream:
print(chunk['message']['content'], end='', flush=True)
# Embeddings
result = ollama.embed(model='llama3.1', input='How to use PostgreSQL indexes')
print(len(result['embeddings'][0])) # embedding dimensions
```
### Step 6: Custom Models with Modelfile
```dockerfile
# Modelfile — Create a custom model with specific behavior
FROM llama3.1
# System prompt baked into the model
SYSTEM """
You are a senior Python developer. You write clean, well-documented code
following PEP 8. You always include type hints and docstrings.
When asked to write code, provide complete, runnable examples.
"""
# Parameters
PARAMETER temperature 0.3
PARAMETER top_p 0.9
PARAMETER num_ctx 8192
```
```bash
# Build and use custom model
ollama create python-coder -f Modelfile
ollama run python-coder
```
### Step 7: GPU Configuration
```bash
# Check GPU detection
ollama ps # shows running models and GPU memory usage
# Environment variables for GPU control
OLLAMA_GPU_LAYERS=35 # number of layers to offload to GPU
CUDA_VISIBLE_DEVICES=0 # select specific GPU
# Memory requirements (approximate):
# 7B model: ~4GB RAM (GPU) or ~8GB RAM (CPU)
# 13B model: ~8GB RAM (GPU) or ~16GB RAM (CPU)
# 70B model: ~40GB RAM (GPU) or ~64GB RAM (CPU)
```
## Examples
### Example 1: Build a private code assistant
**User prompt:** "I want a code assistant that runs entirely on my machine — no code sent to the cloud. Should handle Python and TypeScript."
The agent will:
1. Install Ollama and download `codellama:13b` or `deepseek-coder:6.7b`.
2. Create a Modelfile with a system prompt optimized for coding.
3. Build a simple CLI or web interface using the OpenAI-compatible API.
4. All inference runs locally — zero data leaves the machine.
### Example 2: Run a local RAG pipeline
**User prompt:** "Index my company's internal docs and let employees query them with an AI — but we can't send data to OpenAI due to compliance."
The agent will:
1. Set up Ollama with `llama3.1` for generation and embeddings.
2. Chunk documents and store embeddings in a local vector database (ChromaDB).
3. Build a retrieval pipeline: query → embed → search → generate answer.
4. Deploy as an internal web app. All processing stays on-premises.
## Guidelines
- Model selection by hardware: 7B models run well on 8GB+ RAM machines; 13B needs 16GB+; 70B needs 64GB+ or a high-end GPU. Start with the smallest model that meets quality requirements.
- Ollama's API is OpenAI-compatible — the OpenAI SDK, LangChain, LlamaIndex, and most AI frameworks work by just changing the base URL to `http://localhost:11434/v1`.
- Use GPU acceleration whenever available — inference is 5-10x faster on GPU than CPU. Ollama auto-detects NVIDIA GPUs with CUDA and Apple Silicon's Metal.
- Create custom Modelfiles for specific use cases — baking a system prompt and temperature into the model saves tokens and ensures consistent behavior.
- For production deployments, run Ollama behind a reverse proxy (nginx, Traefik) with authentication. The default API has no auth.
- Keep models updated (`ollama pull model_name`) — the community frequently releases improved quantizations and fine-tunes.Related Skills
zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
zoho
Integrate and automate Zoho products. Use when a user asks to work with Zoho CRM, Zoho Books, Zoho Desk, Zoho Projects, Zoho Mail, or Zoho Creator, build custom integrations via Zoho APIs, automate workflows with Deluge scripting, sync data between Zoho apps and external systems, manage leads and deals, automate invoicing, build custom Zoho Creator apps, set up webhooks, or manage Zoho organization settings. Covers Zoho CRM, Books, Desk, Projects, Creator, and cross-product integrations.
zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
zipkin
Deploy and configure Zipkin for distributed tracing and request flow visualization. Use when a user needs to set up trace collection, instrument Java/Spring or other services with Zipkin, analyze service dependencies, or configure storage backends for trace data.
zig
Expert guidance for Zig, the systems programming language focused on performance, safety, and readability. Helps developers write high-performance code with compile-time evaluation, seamless C interop, no hidden control flow, and no garbage collector. Zig is used for game engines, operating systems, networking, and as a C/C++ replacement.
zed
Expert guidance for Zed, the high-performance code editor built in Rust with native collaboration, AI integration, and GPU-accelerated rendering. Helps developers configure Zed, create custom extensions, set up collaborative editing sessions, and integrate AI assistants for productive coding.
zeabur
Expert guidance for Zeabur, the cloud deployment platform that auto-detects frameworks, builds and deploys applications with zero configuration, and provides managed services like databases and message queues. Helps developers deploy full-stack applications with automatic scaling and one-click marketplace services.
zapier
Automate workflows between apps with Zapier. Use when a user asks to connect apps without code, automate repetitive tasks, sync data between services, or build no-code integrations between SaaS tools.
zabbix
Configure Zabbix for enterprise infrastructure monitoring with templates, triggers, discovery rules, and dashboards. Use when a user needs to set up Zabbix server, configure host monitoring, create custom templates, define trigger expressions, or automate host discovery and registration.
yup
Validate data with Yup schemas. Use when adding form validation, defining API request schemas, validating configuration, or building type-safe validation pipelines in JavaScript/TypeScript.
yt-dlp
Download video and audio from YouTube and other platforms with yt-dlp. Use when a user asks to download YouTube videos, extract audio from videos, download playlists, get subtitles, download specific formats or qualities, batch download, archive channels, extract metadata, embed thumbnails, download from social media platforms (Twitter, Instagram, TikTok), or build media ingestion pipelines. Covers format selection, audio extraction, playlists, subtitles, metadata, and automation.
youtube-transcription
Transcribe YouTube videos to text using OpenAI Whisper and yt-dlp. Use when the user wants to get a transcript from a YouTube video, generate subtitles, convert video speech to text, create SRT/VTT captions, or extract spoken content from YouTube URLs.