New Tool Radar

Local AI

How to List Your Ollama Models Through the API Instead of the CLI

When a script or another app needs your model list, ask Ollama's API — /api/tags lists what is downloaded and /api/ps lists what is loaded — instead of parsing terminal output.

Schematic diagram with three steps: GET /api/tags lists downloaded models, GET /api/ps lists loaded models, and your script reads the JSON fields.

The terminal commands list your models as text, which is fine for a person reading a screen and awkward for a script. Ollama’s local server answers the same questions as JSON, so a script, a dashboard, or another app can read the list without parsing terminal output. The local server is at http://localhost:11434/api, and local requests do not need an API key. Two endpoints cover the two questions people actually ask: what do I have, and what is running right now.

Two endpoints, two questions

Endpoint Question it answers Fields you get back
GET /api/tags Which models are downloaded on this server? For each model: name, size in bytes, digest, and a details object with format, family, parameter_size and quantization_level
GET /api/ps Which models are loaded in memory right now? The same fields, plus size_vram (video memory used), context_length, and expires_at (when the model will be unloaded)

Call them with curl: curl http://localhost:11434/api/tags and curl http://localhost:11434/api/ps. A model that appears in /api/tags but not in /api/ps is on disk but not loaded — it costs disk space, not memory. A model in /api/ps is using memory right now, and size_vram tells you how much video memory it holds. The expires_at field comes from the keep-alive timer: by default models stay in memory for 5 minutes after their last use before being unloaded.

Try it: read the API reference’s own example

The /api/tags reference page shows an example response for a model called gemma4. Read it and answer three questions from the fields, without running anything:

Question Where to look Answer from the example
What is the model’s name? name gemma4
How big is the model, in parameters? details.parameter_size 8.0B
What quantization is it? details.quantization_level Q4_K_M

The same example gives its size as 9608350245 bytes and its digest as a long hex string — the size is the file on disk, and the digest is the model’s fingerprint. The /api/ps example for the same model adds size_vram of 5333539264 and a context_length of 4096, which are only meaningful for a model that is actually loaded. Expected result. We checked the Ollama API reference for /api/tags and /api/ps. We did not call the API on this machine.

Limits

These endpoints describe the server you call, so calling a different machine’s server returns that machine’s models. They list models only; they do not pull, delete, or load one, and they do not tell you which models exist in the Ollama library that you have not downloaded. The local API has no authentication, so anything running on the same machine can read the list. We did not test any API call ourselves.

Sources

See all