v2026.11.0
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.

Model

Ollama model operations: listing, details, pull, copy, delete, create and embeddings

Inherits: EndPoint

Example

models := Model->List();
if(models <> Nil) {
  each(m in models) {
    m->GetPulled()->GetName()->PrintLine();
  };
};

Operations

BuildEmbedRequest # function

Builds the /api/embed request body.

function : BuildEmbedRequest(model:String, inputs:String[], truncate:Bool, dimensions:Int, options:Options) ~ JsonElement

Parameters

NameTypeDescription
modelStringembedding model name
inputsStringtexts to embed
truncateBooltrue to truncate inputs that exceed the context; false makes the server return an error instead
dimensionsIntembedding size for models that support it, or 0 for the model's own
optionsOptionsoptions and request settings (e.g. keep_alive), or Nil

Return

TypeDescription
JsonElementrequest body

Copy # function

Copy a model

function : Copy(src:String, dest:String) ~ Bool

Parameters

NameTypeDescription
srcStringsource name of the model to copy
destStringdestination name of the model to copy

Return

TypeDescription
Booltrue if successful, false otherwise (see EndPoint->GetLastError)

Example

if(Model->Copy("llama3", "llama3-backup")) {
  "Model copied."->PrintLine();
};

Create # function

Create a model from an existing one with a new system prompt

function : Create(name:String, base:String, system:String) ~ Bool

Parameters

NameTypeDescription
nameStringname of the model to create
baseStringname of the model to start from
systemStringsystem prompt, or Nil

Return

TypeDescription
Booltrue if successful, false otherwise (see EndPoint->GetLastError)

Example

if(Model->Create("my-assistant", "llama3", "You are a helpful assistant.")) {
  "Custom model created."->PrintLine();
};

Create # function

Create a model from a Modelfile description. Only servers older than Ollama 0.5.5 accept a Modelfile; newer ones reject the request (see EndPoint->GetLastError), so use Create(name, from, system) with them.

function : Create(name:String, modelfile:String) ~ Bool

Parameters

NameTypeDescription
nameStringname of the model to create
modelfileStringcontents of the Modelfile

Return

TypeDescription
Booltrue if successful, false otherwise

Delete # function

Delete a model and its data.

function : Delete(name:String) ~ Bool

Parameters

NameTypeDescription
nameStringname of the model to delete

Return

TypeDescription
Booltrue if successful, false otherwise (see EndPoint->GetLastError)

Example

if(Model->Delete("llama3")) {
  "Model deleted."->PrintLine();
};

Embed # function

Embeds one text with /api/embed

function : Embed(model:String, input:String) ~ Float[]

Parameters

NameTypeDescription
modelStringembedding model name
inputStringtext to embed

Return

TypeDescription
Floatembedding vector, or Nil with the last error set

Example

vector := Model->Embed("nomic-embed-text", "The sky is blue.");
if(vector <> Nil) {
  "Dimensions: {$vector->Size()}"->PrintLine();
};

Embed # function

Embeds a batch of texts with /api/embed in one request

function : Embed(model:String, inputs:String[]) ~ Float[,]

Parameters

NameTypeDescription
modelStringembedding model name
inputsStringtexts to embed

Return

TypeDescription
Floatone row per input, or Nil with the last error set

Embed # function

Embeds a batch of texts with /api/embed in one request

function : Embed(model:String, inputs:String[], truncate:Bool, dimensions:Int, options:Options) ~ Float[,]

Parameters

NameTypeDescription
modelStringembedding model name
inputsStringtexts to embed
truncateBooltrue to truncate inputs that exceed the context; false makes the server return an error instead
dimensionsIntembedding size for models that support it, or 0 for the model's own
optionsOptionsoptions and request settings (e.g. keep_alive), or Nil

Return

TypeDescription
Floatone row per input, or Nil with the last error set

Example

texts := ["The sky is blue.", "Grass is green."];
embeddings := Model->Embed("nomic-embed-text", texts, true, 0, Nil);
if(embeddings <> Nil) {
  dims := embeddings->Size();
  "{$dims[0]} vectors of {$dims[1]}"->PrintLine();
};

Embeddings # function

Generate embeddings from a model with the older /api/embeddings endpoint (superseded by Embed)

function : Embeddings(model:String, prompt:String) ~ Float[]

Parameters

NameTypeDescription
modelStringname of model to generate embeddings from
promptStringtext to generate embeddings for

Return

TypeDescription
Floatembedding vector as Float array, or Nil with the last error set

Example

embeddings := Model->Embeddings("nomic-embed-text", "The sky is blue.");
if(embeddings <> Nil) {
  "Dimensions: {$embeddings->Size()}"->PrintLine();
};

GetDetails #

Get the model details

method : public : GetDetails() ~ ModelDetails

Return

TypeDescription
ModelDetailsmodel details, or Nil

GetInfo #

Get the model information (Model->Show)

method : public : GetInfo() ~ ModelInfo

Return

TypeDescription
ModelInfomodel information, or Nil

GetPulled #

Get the listing entry (Model->List and Model->Running)

method : public : GetPulled() ~ ModelPulled

Return

TypeDescription
ModelPulledlisting entry, or Nil

List # function

List the models available locally

function : List() ~ Vector<Model>

Return

TypeDescription
Vector<Model>list of models, or Nil with the last error set

Example

models := Model->List();
if(models <> Nil) {
  each(m in models) {
    m->GetPulled()->GetName()->PrintLine();
  };
};

ParseEmbedResponse # function

Parses a /api/embed response body.

function : ParseEmbedResponse(body:String) ~ Float[,]

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Floatone row per input, or Nil with the last error set

ParseModelList # function

Parses a /api/tags or /api/ps response body.

function : ParseModelList(body:String) ~ Vector<Model>

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Vector<Model>models, or Nil with the last error set

ParseShowResponse # function

Parses a /api/show response body.

function : ParseShowResponse(body:String) ~ Model

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Modelmodel, or Nil with the last error set

ParseStatusResponse # function

Parses a {"status": ...} response body (pull, create).

function : ParseStatusResponse(body:String) ~ Bool

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Booltrue if the status is "success"; otherwise false with the last error set

ParseVersionResponse # function

Parses a /api/version response body.

function : ParseVersionResponse(body:String) ~ String

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Stringversion, or Nil with the last error set

Pull # function

Download a model from the ollama library. Waits for the download to finish; no progress is reported.

function : Pull(name:String) ~ Bool

Parameters

NameTypeDescription
nameStringname of the model to pull

Return

TypeDescription
Booltrue if successful, false otherwise (see EndPoint->GetLastError)

Example

if(Model->Pull("llama3")) {
  "Model downloaded successfully."->PrintLine();
};

Running # function

List the models currently loaded in memory

function : Running() ~ Vector<Model>

Return

TypeDescription
Vector<Model>list of models (see ModelPulled->GetSizeVram and GetExpiresAt), or Nil with the last error set

Example

running := Model->Running();
if(running <> Nil) {
  each(m in running) {
    pulled := m->GetPulled();
    name := pulled->GetName(); vram := pulled->GetSizeVram();
    "{$name}: {$vram} bytes VRAM"->PrintLine();
  };
};

Show # function

Show information about a model

function : Show(name:String) ~ Model

Parameters

NameTypeDescription
nameStringname of the model to show

Return

TypeDescription
Modelmodel (see GetInfo and GetDetails), or Nil with the last error set

Example

model := Model->Show("llama3");
if(model <> Nil) {
  model->GetDetails()->GetParameterSize()->PrintLine();
  model->GetInfo()->HasCapability("tools")->PrintLine();
};

ToString #

String representation of the instance

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation of the instance

Version # function

Get the Ollama server version

function : Version() ~ String

Return

TypeDescription
Stringversion (e.g. "0.12.6"), or Nil with the last error set