Install
Install with PiG
pig install npm:@pi-in-go/pigpen-ollama-nativePackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package. This one is published by the PiG project from the Pigpen repository; that is not a verification claim.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"extensions/ollama-native"
]
}README
Written by the package's publisher, shown as published in version 0.2.0 (README.md). PiG does not review it.
ollama-native Package
A PiG model provider for Ollama, through Ollama's native
/api/chat endpoint (not the OpenAI-compatible /v1 one), so tool calls, thinking
and images use Ollama's own message format. Models appear as ollama-native/<model>.
Go extension on PiG's public SDK; PiG builds it from source with a Go toolchain, and a
Piglet Binary can fuse it. It was started by Peder Munksgaard; see CREDITS.md.
It does nothing until you use it. It is not part of any Piglet. It makes no network
call at start-up, so pig starts the same with Ollama stopped. It asks Ollama for
anything only when PiG refreshes provider catalogs, when you run /ollama refresh, or
when you send a message to an ollama-native model.
Set up
Install and start Ollama, and pull a model that supports tools:
ollama pull granite4.1:3b(orqwen3:8b,llama3.2, and so on).Install the Package from the Pigpen checkout root:
pig package validate ./components/ollama-native pig install ./components/ollama-nativeThe local install references this checkout; keep it where it is and remove it with
pig removeusing the same path. To try it without installing, load the source directly:pig -e ./components/ollama-native/extensions/ollama-native.Load the model list once. Start
piginteractively (PiG refreshes provider catalogs when a session starts) or run/ollama refresh. The list is stored, so later runs, including one-shotpig -p, find the models with Ollama not asked:pig --list-models ollama pig --model ollama-native/granite4.1:3b -p "Say hello"
Run /ollama refresh again after ollama pull or ollama rm.
Configuration
| Variable | Meaning | Default |
|---|---|---|
OLLAMA_HOST | Where Ollama listens: host, host:port, :port or a full http(s):// URL, as Ollama's own tools read it. | http://127.0.0.1:11434 |
OLLAMA_API_KEY | Sent as Authorization: Bearer to a protected server (a proxy, Ollama's hosted service). A local Ollama needs none, and no key is ever sent unless this is set. | unset |
PI_OFFLINE=1 (or --offline) keeps PiG from refreshing catalogs on its own.
What it does
- Models come from
/api/tags; none is written down in the code. For each model/api/showgives the context length and capabilities:thinkingmarks a reasoning model,visionadds image input, and a model withoutcompletion(an embedding model) is left out. When/api/showfails the model is still listed, with a 32,768 token context window. - Chat streams
/api/chat: text, thinking, and any number of tool calls per answer. Ollama sends no tool-call ids, so each call gets one. Tool results go back astoolmessages. Token counts come from Ollama's final message. Cancelling a turn closes the request. - Errors say what to do: Ollama not reachable (start it with
ollama serveor setOLLAMA_HOST), a model that is not installed (ollama pull <model>), or the message Ollama returned, including one that arrives in the middle of a stream. - Stream options follow Pi's
StreamOptions/SimpleStreamOptions:temperatureandmaxTokensbecome Ollama'stemperatureandnum_predict.samplingParamspass into Ollama'soptionsper key and win over those two, sotop_p,top_k,min_p,seed,stop,repeat_penalty,num_ctxand the rest of Ollama's options work.thinkis sent only to models marked as reasoning, and only when thinking is asked for: fromthinkingEnabled, else the level (reasoning, thenreasoningEffort, theneffort).offsendsfalse.gpt-ossmodels take a level, so minimal/low sendlow, mediummedium, high/xhigh/maxhigh; other models gettrue.toolChoice: "none"leaves the tools out of the request. Other values, and adeferredrequest, are refused with an error and nothing is sent.headersare added to the request over the defaults (anullvalue removes a default header).envgives a request its ownOLLAMA_HOSTandOLLAMA_API_KEY.timeoutMsbounds the wait for Ollama's response (not the stream).maxRetriesretries connection failures, timeouts and 408/409/429/5xx answers, waiting forRetry-Afteror 0.5 s doubling to 8 s; a wait overmaxRetryDelayMs(default 60 s,0for no cap) fails at once. No retries unlessmaxRetriesis set.- Pi documents
sessionId,cacheRetention,transport,websocketConnectTimeoutMs,thinkingBudgets,thinkingBudgetTokens,interleavedThinking,metadata,requestMetadata,regionandprofileas hints a provider without the feature ignores. Ollama has no equivalent, so they are accepted and change nothing.
- Hooks:
onPayloadsees the/api/chatbody and may replace it (returning nothing keeps it);onResponsesees the HTTP status and lowercased headers before the body is read;onProviderStreamEventsees each parsed/api/chatline before it becomes a PiG event. An error from a hook ends the turn with that error.
Limits
- Tool calls need a model that supports them. Ollama says so in the error when it does not.
- PiG 0.4.0 gives a provider the system prompt's named sections as an unordered map, so they are sent in name order, not PiG's authored order. The text is all there.
- The catalog's
maxTokensis 8,192 (or the context window if smaller); PiG sends a limit only when you set one. - Only chat is covered: no embeddings, no model management (pull, delete). This is a scope choice, not a gap against an original: the README has always said "model provider for chat". Owner decision pending; the recommendation is to keep it, since Pi's provider contract has no embeddings or model-management operation to map them onto.
Tests
extensions/ollama-native/testdata/ holds the Ollama responses the tests replay from a
local HTTP server: /api/tags, /api/show and the /api/chat streams (text,
thinking, tool calls, length stop, a mid-stream error, a truncated body, a 404). They
are written to the wire format in Ollama's API documentation, not recorded from a live
server. go test ./... in extensions/ollama-native runs them; nothing needs Ollama.
No Ollama was reachable on the machines the port was built on, so a run against a real
server has not been done; that is the owner's check.