Skip to main content
List all models that are locally installed and available on your Ollama server. This function provides detailed information about each model including size, family, parameters, and when it was last modified.

Samples

List all models

See all installed models:
SELECT * FROM ai.ollama_list_models();
Returns:
    name     |    model     |    size    |   digest   | family  | format | ...
-------------+--------------+------------+------------+---------+--------+-----
 llama2      | llama2:latest| 3825819519 | sha256:... | llama   | gguf   | ...
 mistral     | mistral:7b   | 4109865159 | sha256:... | mistral | gguf   | ...
 codellama   | codellama:7b | 3825819519 | sha256:... | llama   | gguf   | ...

Connect to specific host

List models from a remote Ollama server:
SELECT * FROM ai.ollama_list_models(
    host => 'http://ollama-server:11434'
);

Filter by model name

Find a specific model:
SELECT name, size, modified_at
FROM ai.ollama_list_models()
WHERE name LIKE 'llama%';

Check model sizes

See how much disk space models are using:
SELECT
    name,
    pg_size_pretty(size) AS disk_space,
    modified_at
FROM ai.ollama_list_models()
ORDER BY size DESC;

Arguments

NameTypeDefaultRequiredDescription
hostTEXTNULLOllama server URL (defaults to http://localhost:11434)
verboseBOOLEANFALSEEnable verbose logging for debugging

Returns

TABLE: A table with the following columns:
ColumnTypeDescription
nameTEXTModel name (e.g., llama2, mistral:7b)
modelTEXTFull model identifier
sizeBIGINTModel size in bytes
digestTEXTSHA256 digest of the model
familyTEXTModel family (e.g., llama, mistral)
formatTEXTModel format (typically gguf)
familiesJSONBArray of model families
parent_modelTEXTParent model if this is a derivative
parameter_sizeTEXTNumber of parameters (e.g., 7B, 13B)
quantization_levelTEXTQuantization level (e.g., Q4_0, Q5_K_M)
modified_atTIMESTAMPTZLast modification timestamp