Ollama Tutorial

Welcome to the Ollama tutorial. It follows the official Ollama docs and the ollama/ollama project so you can run open models on your machine (or Ollama Cloud) and wire them into apps through the CLI, REST, and an OpenAI-compatible API.

Ollama packages download, local inference, and an HTTP server into one workflow: after install, ollama run gemma4 starts a chat, and http://localhost:11434/api accepts requests. Code, notes, and customer text can stay on-device—you do not need a cloud vendor account just to try a prompt.


Table of Contents

Basics

  1. Introduction — Local LLM runtime, vs vLLM / cloud APIs, privacy
  2. Installation — macOS / Windows / Linux, ollama --version, GPU and VRAM
  3. Quick Start — Interactive menu, pull / run / /bye, ls / ps / stop

Models and APIs

  1. Models and quantization — Library, tags, quantization, cloud models
  2. REST and OpenAI-compatible API/api/generate, /api/chat, /api/embed, /v1
  3. Python and JavaScript — Official ollama libraries, streaming, Client

Customization and retrieval

  1. ModelfileFROM, SYSTEM, PARAMETER, ollama create
  2. Embeddings and a RAG teaser — Embed models, vector API, LangChain RAG

Integration and practice

  1. Integrations — Dify, LangChain, Hermes / OpenClaw, Cursor, Docker networking
  2. Practical examples — Local Q&A CLI, OpenAI-compatible client, coding Modelfile
  3. Resources — Official docs, model library, GitHub

Learning path

StageGoalChapters
First hourInstall and finish one chatIntro → Install → Quick Start
Day 1Pick a model and hit HTTPModels → REST / OpenAI API
Days 2–3Script and customizePython/JS → Modelfile → Embeddings
Week 1Plug into existing toolsIntegrations → Examples

Prerequisites

  • Comfort with a terminal (macOS / Linux bash, or Windows PowerShell / curl.exe)
  • The ideas of model, prompt, and token
  • Disk space: models are often several GB to tens of GB
  • Optional: an NVIDIA GPU (CUDA) or Apple Silicon (Metal). CPU-only works, just slower

Conventions in this tutorial

  • Official quickstart currently uses gemma4. Library tags change—trust ollama.com/library. For Chinese-heavy work try qwen2.5; Llama-family tags are common general alternatives.
  • Local API base: http://localhost:11434/api. OpenAI-compatible base: http://localhost:11434/v1.
  • Cloud uses the same API shape at https://ollama.com/api (account / API key).
  • Commands and model names in docs.ollama.com win when this page and the site disagree.

What you can do after this course

  • Install on macOS / Windows / Linux and confirm ollama --version
  • Finish a local chat with gemma4 (or qwen2.5 / Llama) and leave with /bye
  • Land one request each on http://localhost:11434/api and http://localhost:11434/v1 (PowerShell or curl.exe on Windows)
  • Write a Modelfile and ollama create a reusable assistant name
  • Point Dify, LangChain, Cursor, or a Dockerized app at Ollama
CourseRelationship
LangChainAgents and RAG on local or cloud models
DifyOllama as a model provider in app orchestration
Hugging FaceWeights, GGUF, and quantization vocabulary
Hermes / OpenClawSelf-hosted agents that can use Ollama as the backend

Next steps

评论