Skip to content

OllamaAdapter ​

Category: Providers

Source: ollama_adapter.dart

Adapter that talks to Ollama's native /api/chat via [OllamaClient].

Previously Ollama rode the OpenAI-compat adapter (/v1/chat/completions). That worked for simple chat, but left three problems unresolved:

  1. Error messages said "OpenAI API error 404" on missing Ollama models, which confuses every user who sees it.
  2. options.num_ctx — the fix for Ollama's silent-truncation-at-2048 footgun — has no place in an OpenAI-shaped body. Native /api/chat takes it cleanly.
  3. Future Ollama-specific options (think, keep_alive, model-load hints) would have no home without adding branching logic into OpenAiClient.

Moving Ollama to its own adapter + client keeps per-vendor quirks in per-vendor files.

Classes ​

OllamaAdapter ​

Constructor ​

dart
OllamaAdapter({this._requestClientFactory})

Properties ​

PropertyTypeDescription
adapterIdString get
adapterIdString get

Methods ​

ProviderHealth validate(ResolvedProvider provider) ​
bool isConnected(ProviderDef provider, CredentialStore store) ​
`LlmClient createClient({ ​
required ResolvedProvider provider,
required ResolvedModel model,
required String systemPrompt,

})`

Released under the MIT License.