Tool cheatsheet
Ollama Cheatsheet
Run large language models locally: pull and run models, customize them with a Modelfile, call the REST API, and configure the server.
Running models
- Check the Ollama version — Print the installed Ollama version.
- Download a model — Download a model from the Ollama library without running it.
- Chat with a model — Start an interactive chat. The model is downloaded first if needed. Type /bye to leave.
- Ask a single question — Answer one prompt and exit, which suits scripts.
- Summarize a file — Pass the contents of a file inside the prompt.
- Ask about an image — Use a multimodal model and give the path to an image in the prompt.
- List downloaded models — Show the models on this machine with their sizes.
- See loaded models — Show models currently loaded in memory and whether they use the GPU.
- Show model details — Print a model's parameters, template and license.
- Unload a model — Free the memory used by a loaded model.
- Copy a model — Create another name for an existing model.
- Delete a model — Remove a model from disk.
Commands inside a chat
- Change a parameter — Set the sampling temperature for the rest of the session. Lower values give more predictable answers.
- Set a system prompt — Give the model standing instructions for the session.
- Show the model's info — Print information about the current model.
- Save the session as a model — Save the current settings and conversation as a new model.
- Enter a multi-line prompt — Wrap text in triple quotes to type several lines.
- Leave the chat — Exit the interactive session.
Customizing models
- Write a Modelfile — Define a custom model from a base model, with a system prompt and parameters.
- Build a model from a Modelfile — Create a model that you can run by name.
- See a model's Modelfile — Print the Modelfile that a model was built from, a good starting point for your own.
- Publish a model — Upload a model to your account on ollama.com. The name must start with your username.
REST API
- Generate text — Send a prompt to the generate endpoint. Setting stream to false returns one JSON response.
- Chat with message history — Send a list of messages, including earlier turns.
- Create embeddings — Turn text into a vector, using an embedding model such as nomic-embed-text.
- List models over the API — Return the locally available models as JSON.
- Use the OpenAI-compatible endpoint — Call the chat completions endpoint so tools built for the OpenAI API work with Ollama.
- Use the Python library — Install the client and chat with a model from Python.
- Use the OpenAI Python client — Point the OpenAI client at your local server. The API key is required but ignored.
Server and deployment
- Start the server — Start the Ollama server manually, if it isn't already running as a service.
- Listen on all network interfaces — Allow other machines to reach the server. By default it listens only on localhost.
- Store models elsewhere — Change where models are saved, for example to a larger disk.
- Keep a model loaded longer — Keep models in memory for an hour after the last request instead of the default five minutes.
- Run in Docker — Start Ollama in a container with a volume for models.
- Run in Docker with NVIDIA GPUs — Give the container access to all GPUs. Needs the NVIDIA Container Toolkit.
- Run a model inside the container — Run a model with the container's Ollama.
- Read the server logs on Linux — Follow the logs of the systemd service.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.