Ollama

Ollama is an open-source tool for running large language models locally. It supports a wide range of models including Llama, Mistral, Gemma, Phi, and many others, enabling local AI inference without requiring cloud API access.

The sgcWebSockets library provides a Delphi component TsgcHTTP_API_Ollama to interact with the Ollama API.

Ollama API

The Ollama API provides access to locally running models for AI-powered applications. The API supports text generation, streaming, model management, and embeddings. No API key is required by default since models run locally. The host and port are configurable.

Features

Configuration

Ollama runs locally and by default listens on http://localhost:11434. Configure the host in the OllamaOptions.Host property. An API key is optional and only needed if you have configured authentication on your Ollama instance.


Ollama := TsgcHTTP_API_Ollama.Create(nil);
Ollama.OllamaOptions.Host := 'http://localhost:11434';

Messages

Send a structured list of input messages with text content, and the model will generate the next message in the conversation.

Models

Manage and query locally available models.

Embeddings

Generate vector embeddings from text input using locally running models.