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.

Completion

Ollama model interactions

Inherits: EndPoint

Example

prompt := "What number is this?";
file := System.IO.Filesystem.File->New("../gemini/thirteen.png");
Completion->Generate("llava", prompt, file)->PrintLine();

Operations

BuildGenerateRequest # function

Builds the /api/generate request body every Generate overload sends.

function : BuildGenerateRequest(model:String, prompt:String, format:String, options:Options, images:File[]) ~ JsonElement

Parameters

NameTypeDescription
modelStringmodel name
promptStringprompt
formatStringoutput format ("json"), or Nil
optionsOptionsoptions and request settings, or Nil
imagesFile[]image files, or Nil

Return

TypeDescription
JsonElementrequest body, or Nil with the last error set if an image cannot be read

Generate # function

Generates a response from the model given an input

function : Generate(model:String, prompt:String) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt

Return

TypeDescription
Stringquery response, or Nil with the last error set

Example

response := Completion->Generate("llama3", "What is the capital of France?");
response->PrintLine();

Generate # function

Generates a response from the model given an input with options

function : Generate(model:String, prompt:String, options:Options) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
optionsOptionsoptions and request settings (temperature, top_p, format, think, etc.)

Return

TypeDescription
Stringquery response, or Nil with the last error set

Example

opts := Options->New()->SetTemperature(0.3)->SetTopP(0.85);
response := Completion->Generate("llama3", "Summarize quantum entanglement briefly.", opts);
response->PrintLine();

Generate # function

Generates a response from the model given an input

function : Generate(model:String, prompt:String, format:String) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
formatStringoutput format ("json")

Return

TypeDescription
Stringquery response, or Nil with the last error set

Generate # function

Generates a response from the model given an input

function : Generate(model:String, prompt:String, format:String, options:Options) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
formatStringoutput format ("json"); for a JSON schema use Options->SetFormat
optionsOptionsoptions and request settings, or Nil

Return

TypeDescription
Stringquery response, or Nil with the last error set

Generate # function

Generates a response from the model given an input

function : Generate(model:String, prompt:String, image:File) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
imageFileimage file

Return

TypeDescription
Stringquery response, or Nil with the last error set

Example

image := System.IO.Filesystem.File->New("photo.png");
response := Completion->Generate("llava", "Describe what you see in this image.", image);
response->PrintLine();

Generate # function

Generates a response from the model given an input

function : Generate(model:String, prompt:String, images:File[]) ~ String

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
imagesFile[]image files

Return

TypeDescription
Stringquery response, or Nil with the last error set

GenerateReply # function

Generates a reply with its metadata (thinking, done reason, token counts, timings)

function : GenerateReply(model:String, prompt:String, options:Options) ~ Reply

Parameters

NameTypeDescription
modelStringmodel name (i.e. llama3, llava)
promptStringprompt
optionsOptionsoptions and request settings, or Nil

Return

TypeDescription
Replyreply, or Nil with the last error set

GenerateReply # function

Generates a reply about images, with its metadata

function : GenerateReply(model:String, prompt:String, images:File[], options:Options) ~ Reply

Parameters

NameTypeDescription
modelStringmodel name (i.e. llava)
promptStringprompt
imagesFile[]image files, or Nil
optionsOptionsoptions and request settings, or Nil

Return

TypeDescription
Replyreply, or Nil with the last error set

ParseGenerateResponse # function

The response handling behind every Generate overload, as a function of the body text so it can be tested without a server.

function : ParseGenerateResponse(body:String) ~ String

Parameters

NameTypeDescription
bodyStringresponse text from /api/generate

Return

TypeDescription
Stringthe generated text, or Nil with the last error set