Delphi Ollama Client
Run open-source large language models locally from your Delphi, C++ Builder and .NET applications. Inference stays private, offline and on-premise, executing on your own hardware with no cloud API required.
Run open-source large language models locally from your Delphi, C++ Builder and .NET applications. Inference stays private, offline and on-premise, executing on your own hardware with no cloud API required.
Ollama REST API client for local chat completions, embeddings and model management.
TsgcHTTP_API_Ollama
Ollama REST API over HTTP
Windows, macOS, Linux, iOS, Android
Enterprise / sgcAI
Ollama runs locally and needs no API key. Set OllamaOptions.Host to your local server (default http://localhost:11434), then call _CreateMessage or build a TsgcOllamaClass_Request_ChatCompletion and call CreateMessage.
uses
sgcHTTP_API_Ollama;
var
Ollama: TsgcHTTP_API_Ollama;
begin
Ollama := TsgcHTTP_API_Ollama.Create(nil);
// Local server, no API key needed
Ollama.OllamaOptions.Host := 'http://localhost:11434';
// Simple one-shot message
Memo1.Lines.Text := Ollama._CreateMessage(
'llama3',
'What are the benefits of WebSockets?');
// Streaming — handle OnHTTPAPISSE per chunk
Ollama.OnHTTPAPISSE := HandleSSE;
Ollama._CreateMessageStream(
'llama3',
'Summarise RFC 6455');
end;
procedure TForm1.HandleSSE(Sender: TObject;
const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aEvent + ': ' + aData);
end;
// uses: sgcHTTP_API_Ollama
TsgcHTTP_API_Ollama *Ollama = new TsgcHTTP_API_Ollama(this);
// Local server, no API key needed
Ollama->OllamaOptions->Host = "http://localhost:11434";
// Simple one-shot message
Memo1->Lines->Text = Ollama->_CreateMessage(
"llama3",
"What are the benefits of WebSockets?");
// Streaming — OnHTTPAPISSE fires per chunk
Ollama->OnHTTPAPISSE = HandleSSE;
Ollama->_CreateMessageStream(
"llama3",
"Summarise RFC 6455");
using esegece.sgcWebSockets;
var ollama = new TsgcHTTPAPI_Ollama();
// Local server, no API key needed
ollama.OllamaOptions.Host = "http://localhost:11434";
// Simple one-shot message
Console.WriteLine(ollama._CreateMessage(
"llama3",
"What are the benefits of WebSockets?"));
// Streaming request, returns the complete text
Console.WriteLine(ollama._CreateMessageStream(
"llama3",
"Summarise RFC 6455"));
The .NET assembly exposes no per-chunk streaming event. _CreateMessageStream issues the streaming request and returns the complete text once the stream ends. For token-by-token delivery, use the OnHTTPAPISSE event shown on the Delphi and C++ Builder tabs.
Typed request / response classes for chat completions and embeddings, plus model management and streaming over Server-Sent Events.
CreateMessage sends a typed TsgcOllamaClass_Request_ChatCompletion and returns a parsed response. _CreateMessage, _CreateMessageWithSystem and _CreateMessageStream are string shortcuts, with streaming deltas delivered through OnHTTPAPISSE.
CreateEmbeddings turns input text into a dense vector using a locally pulled embedding model such as nomic-embed-text or mxbai-embed-large, returning a TsgcOllamaClass_Response_Embeddings.
Manage the models on your machine: _GetModels and _GetTags list what is available, _ShowModel reads model details, _PullModel downloads from the Ollama library and _DeleteModel removes a local model.
Every request targets a local Ollama server (default http://localhost:11434) so no data leaves your network and no API key is required. Point OllamaOptions.Host at a remote or containerized instance when you need to.
CircuitBreaker short-circuits requests when the server is unhealthy; ReadTimeout and TLSOptions tune the HTTP/HTTPS layer; OnHTTPAPIException surfaces failures; OnHTTPAPISSE streams server-sent events.
Authoritative sources for the protocols this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — Ollama Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\AI\Ollama Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |