Can an AI agent drive Ollama?
Claude Code uses Ollama as a local model server for tests and comparisons. Commands, API results, wrong answers and what to check before trusting it.
Yes, and it’s one of the easier tools here, because it’s a local HTTP server. Claude Code has used Ollama as a stand-in model server when testing software that talks to a model, and to compare models on one Mac. The tool works well for this. The small model I ran, Llama 3.2 3B, got simple questions wrong, so I wouldn’t treat its answers as fact.
| Verdict | |
|---|---|
| Call the local API from a script | Works |
| Use it through an OpenAI-style endpoint | Works |
| Get JSON back | Works in the test here; see the schema note below |
| Same answer on a repeat call | Works: fixed seed and temperature 0, on one prompt |
| Report failure | Works: HTTP 404 and exit 1 for a missing model |
| Trust the model’s answers | Didn’t work: 3 of 5 right in a quick quiz |
| Check its own work | Works with limits: it can test the format, not the truth |
| Quit the app by script | Didn’t work: “User canceled” |
| Run unattended | Works with limits: calls needed no prompts; SSH and schedules not tried |
The way in
Ollama listens on 127.0.0.1:11434. A script can call it without any key:
curl -s http://127.0.0.1:11434/api/generate -d '{
"model": "llama3.2:3b",
"prompt": "Reply with JSON only: a key named sum holding 2+2.",
"stream": false,
"format": "json",
"options": {"seed": 7, "temperature": 0}
}'That returned {"sum": 4} in its response field. The same model also answers at
/v1/chat/completions, so software built for OpenAI’s API format can point at it. There’s a
command line too:
ollama run llama3.2:3b 'Say only the word pong.'Real tasks
Testing a tool that needs a model. Apple’s fm command can use other model servers, so
Claude pulled the 2 GB llama3.2:3b and pointed fm at Ollama. That’s in
the fm guide. An image request came back as
a clear HTTP 400 because this model only handles text. That’s the kind of case a local server lets
you test without an account or a bill.
Comparing models. Claude also ran one set of tests against both Llama and Apple’s on-device model on the same Mac. The local API made it cheap to rerun, and its first low scores for Llama pointed to a mistake, listed below.
What failed
- A low score that was partly the harness. Llama did badly through
fmon a four-field schema. It turned outfmsends the schema’s fields in a different order each time. Sent directly, with the order kept, the same model did better. The fm guide has the numbers. Test the model directly before you blame it. - Wrong answers. In a five-question quiz, it got
17*23and the capital of Australia right, saidstrawberryhas 2 r’s, and said 9.11 is larger than 9.9. It also got PostgreSQL’s port right. That’s a small sample, on one small model. - A “read-only” check. With the app closed,
ollama --versionwarnedcould not connect,ollama listprintedtimed out waiting for server to start, and the app launched anyway. A check can leave a server running. - A typo reaches for the network.
ollama run zz-none hiansweredpull model manifest: file does not existand exited 1. Soruntries to download a model it doesn’t have. With a real name, an agent could start a large download by accident. - Quitting. Telling Ollama to quit through AppleScript failed twice with
User canceled(-128). I don’t know why. It was still running, listening on127.0.0.1only, when I finished this page. - My own quiz script. Its first version had a quoting bug, so the first run tested nothing.
Can it check its own work?
Partly, and it depends what’s being tested. An agent can check status codes, whether the JSON parses, and whether a repeat matches. In my test, three runs with one seed and temperature 0 were identical. It can’t get the truth from the model, so for a real test, score answers against known ones.
Determinism has limits. Two different seeds at temperature 0 also began with the same 50 characters, so don’t expect a new seed alone to give you variety.
Timing and memory
The first call took about 28 seconds, nearly all of it loading the model, and a repeat took 119
milliseconds. My model is on an SD card, so an internal drive may load faster, and I didn’t measure
that. While loaded, ollama ps showed 6.0 GB for a 2 GB model on my 16 GB Mac, with an unload
timer of a few minutes. Before running this alongside other heavy jobs, check ollama ps.
Can it run unattended?
Partly. None of these calls asked for anything, and failures came back as errors a script can read. I haven’t tried it over SSH, with the environment stripped, or on a schedule.
Security
- No key on the API: none of my calls sent one, so anything running as any user on this Mac
can probably call it. Mine listened only on
127.0.0.1. Don’t expose it to a network without thinking about that. - Local isn’t the same as private by proof: I didn’t inspect Ollama’s network traffic, so I’m not claiming nothing leaves the Mac.
- Downloads: a pull downloads whatever model file you name, and running it means trusting it. I used one model from Ollama’s library, and pinned nothing beyond its tag.
- Files:
~/.ollamaholds an ed25519 key pair and logs. I didn’t inspect them. - Model output is untrusted: don’t let a script run what a model returns.
Not tried
- Tool calling, which this model lists as a capability
- Other models, or Ollama’s cloud features
- Vision models
- Running over SSH or on a schedule
- Several requests at once
Tested on
Ollama 0.40.14 with llama3.2:3b on an M2 Pro MacBook Pro with 16 GB, macOS 27.2, on November 4,
2026. The fm work used 0.40.13, in late October.