v2026.11.3
All Bundles
Bundle

Ollama local LLM client. Runs models (Llama, Mistral, Phi, Qwen, etc.) locally via the Ollama server. Supports text generation, chat sessions with tool calling, structured (JSON schema) output, thinking models, images, batch embeddings and model management. Every request completes before returning -- responses are not streamed, so a long generation produces nothing until it finishes. Compile with -lib ollama.

Options

Generation options and request settings. Model parameters (temperature, top_p, num_ctx, seed, stop, ...) are sent in the request's 'options' object; request settings (format, think, keep_alive, and for Completion system, template, suffix and raw) are sent as top-level request fields.

Example

schema := JsonParser->TextToElement("{\"type\":\"object\",\"properties\":{\"answer\":{\"type\":\"integer\"}},\"required\":[\"answer\"]}");
options := Options->New();
options->SetTemperature(0.0)->SetSeed(42)->SetNumCtx(8192);
options->SetFormat(schema)->SetKeepAlive("10m");

Operations

ApplyTo #

Adds the model parameters and request settings to a request body.

method : public : ApplyTo(request:JsonElement, generate:Bool) ~ Nil

Parameters

NameTypeDescription
requestJsonElementrequest body
generateBooltrue for an /api/generate request; system, template, suffix and raw are sent only then

Set #

Sets any numeric model parameter by name (see the Modelfile parameter list).

method : public : Set(name:String, value:Float) ~ Options

Parameters

NameTypeDescription
nameStringparameter name
valueFloatparameter value

Return

TypeDescription
Optionsself for chaining

Set #

Sets any integer model parameter by name (see the Modelfile parameter list).

method : public : Set(name:String, value:Int) ~ Options

Parameters

NameTypeDescription
nameStringparameter name
valueIntparameter value

Return

TypeDescription
Optionsself for chaining

SetFormat #

Sets the output format to "json" (any JSON value).

method : public : SetFormat(format:String) ~ Options

Parameters

NameTypeDescription
formatString"json"

Return

TypeDescription
Optionsself for chaining

SetFormat #

Sets the output format to a JSON schema (structured output); the reply text is JSON matching the schema.

method : public : SetFormat(schema:JsonElement) ~ Options

Parameters

NameTypeDescription
schemaJsonElementJSON schema

Return

TypeDescription
Optionsself for chaining

SetKeepAlive #

Sets how long the model stays loaded after the request (e.g. "5m", "1h", "0" to unload).

method : public : SetKeepAlive(duration:String) ~ Options

Parameters

NameTypeDescription
durationStringkeep-alive duration

Return

TypeDescription
Optionsself for chaining

SetMinP #

Sets the min-p sampling value.

method : public : SetMinP(p:Float) ~ Options

Parameters

NameTypeDescription
pFloatmin-p value (0.0 to 1.0)

Return

TypeDescription
Optionsself for chaining

SetNumCtx #

Sets the context window size in tokens.

method : public : SetNumCtx(n:Int) ~ Options

Parameters

NameTypeDescription
nIntcontext size

Return

TypeDescription
Optionsself for chaining

SetNumPredict #

Sets the maximum number of tokens to generate (-1 for no limit).

method : public : SetNumPredict(n:Int) ~ Options

Parameters

NameTypeDescription
nInttoken limit

Return

TypeDescription
Optionsself for chaining

SetRaw #

Sends the prompt without applying the prompt template (Completion only).

method : public : SetRaw(raw:Bool) ~ Options

Parameters

NameTypeDescription
rawBooltrue for a raw prompt

Return

TypeDescription
Optionsself for chaining

SetRepeatPenalty #

Sets the repeat penalty.

method : public : SetRepeatPenalty(penalty:Float) ~ Options

Parameters

NameTypeDescription
penaltyFloatpenalty value (1.0 is no penalty)

Return

TypeDescription
Optionsself for chaining

SetSeed #

Sets the random seed, for reproducible output.

method : public : SetSeed(seed:Int) ~ Options

Parameters

NameTypeDescription
seedIntseed value

Return

TypeDescription
Optionsself for chaining

SetStop #

Sets the stop sequences; generation ends when one is produced.

method : public : SetStop(stops:String[]) ~ Options

Parameters

NameTypeDescription
stopsStringstop sequences

Return

TypeDescription
Optionsself for chaining

SetSuffix #

Sets the text that follows the generated text, for fill-in-the-middle (Completion only).

method : public : SetSuffix(suffix:String) ~ Options

Parameters

NameTypeDescription
suffixStringsuffix text

Return

TypeDescription
Optionsself for chaining

SetSystem #

Sets the system prompt, overriding the Modelfile's (Completion only; a Chat takes a "system" message instead).

method : public : SetSystem(system:String) ~ Options

Parameters

NameTypeDescription
systemStringsystem prompt

Return

TypeDescription
Optionsself for chaining

SetTemperature #

Sets the temperature (0.0 to 2.0). Lower is more deterministic.

method : public : SetTemperature(t:Float) ~ Options

Parameters

NameTypeDescription
tFloattemperature value

Return

TypeDescription
Optionsself for chaining

SetTemplate #

Sets the prompt template, overriding the Modelfile's (Completion only).

method : public : SetTemplate(template:String) ~ Options

Parameters

NameTypeDescription
templateStringprompt template

Return

TypeDescription
Optionsself for chaining

SetThink #

Enables or disables thinking for thinking models; the reasoning is returned separately (see Reply->GetThinking).

method : public : SetThink(think:Bool) ~ Options

Parameters

NameTypeDescription
thinkBooltrue to think

Return

TypeDescription
Optionsself for chaining

SetThink #

Sets the thinking level for models that support levels ("low", "medium" or "high").

method : public : SetThink(level:String) ~ Options

Parameters

NameTypeDescription
levelStringthinking level

Return

TypeDescription
Optionsself for chaining

SetTopK #

Sets the top-k sampling value.

method : public : SetTopK(k:Int) ~ Options

Parameters

NameTypeDescription
kInttop-k value

Return

TypeDescription
Optionsself for chaining

SetTopP #

Sets the top-p (nucleus sampling) value.

method : public : SetTopP(p:Float) ~ Options

Parameters

NameTypeDescription
pFloattop-p value (0.0 to 1.0)

Return

TypeDescription
Optionsself for chaining

ToJson #

Converts the model parameters to JSON for the request's 'options' object.

method : public : ToJson() ~ JsonElement

Return

TypeDescription
JsonElementJSON element, or Nil if no model parameters are set