ollama / ollama/ollama-python

feat: add client.exists() or client.has_model() method to check if a model is available locally

Open
#640 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.5k
Forks
1.2k
Avg merge
4m
Merged PRs (30d)
1

Description

Feature Request

Currently there is no clean way to check whether a model is already pulled locally without either:

  1. Calling ollama.show(model) and catching the exception
  2. Calling ollama.list() and iterating through all models

Proposed API

import ollama

if not ollama.exists("llama3.1:8b"):
    ollama.pull("llama3.1:8b")

Or on the client:

client = ollama.Client()
if not client.exists("llama3.1:8b"):
    client.pull("llama3.1:8b")

Use Case

When building applications that need to ensure a model is available before running inference (e.g., CI pipelines, first-run setup scripts, or tools like factory floor AI systems that need to work offline), a simple boolean check is much cleaner than exception-based flow control.

Current Workaround

try:
    ollama.show("llama3.1:8b")
except ollama.ResponseError:
    ollama.pull("llama3.1:8b")

This works but is not discoverable and uses exceptions for control flow, which is an anti-pattern in Python.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing show(), list(), pull(), and Client entry points to understand how local model availability is currently determined. Define the chosen module-level and client API consistently, then add coverage showing that an available model and a missing model produce the intended boolean result.

Written by the indexing model from the issue text.

Assessment

Tech stack
ollama, python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.