OllamaClient class
Low-level Ollama HTTP client. Stateless, pure Dart, no Flutter dependency.
Supports the full Ollama REST API:
- Status check, model listing, model info
- Pull (download) with streaming progress
- Create model from Modelfile
- Delete model
- Chat (native + OpenAI-compatible)
Constructors
- OllamaClient({String host = 'http://localhost:11434', Duration timeout = const Duration(seconds: 5)})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- host → String
-
final
-
isRunning
→ Future<
bool> -
Whether Ollama is running (convenience).
no setter
- openAiBaseUrl → String
-
OpenAI-compatible base URL for providers that use /v1/chat/completions.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeout → Duration
-
final
Methods
-
chat(
String model, String prompt, {String? system}) → Future< String> -
Single-turn chat (native Ollama API). Returns response text with any
<think>…</think>reasoning block stripped (user-visible content only). -
chatStream(
String model, String prompt, {String? system}) → Stream< String> - Streaming chat (native Ollama API). Yields text chunks.
-
chatWithThinking(
String model, String prompt, {String? system, bool enableThinking = true}) → Future< OllamaChatResult> - Single-turn chat that also exposes the reasoning trace.
-
checkStatus(
) → Future< OllamaStatus> - Check if Ollama server is reachable.
-
createModel(
String name, String modelfile) → Future< bool> - Create a model from a Modelfile string.
-
deleteModel(
String name) → Future< bool> - Delete a local model.
-
hasModel(
String name) → Future< bool> - Check if a specific model is installed.
-
listModels(
) → Future< List< OllamaModel> > - List all locally available models.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pullModel(
String name) → Stream< OllamaPullProgress> - Pull (download) a model. Streams progress updates.
-
showModel(
String name) → Future< OllamaModel?> - Get detailed info about a model.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited