dart_ollama library

A Dart package for interacting with Ollama and ChatGPT APIs.

This package provides a simple wrapper for Ollama and ChatGPT APIs with support for:

  • Streaming chat responses
  • Tool/function calling
  • Image support
  • Both Ollama and ChatGPT backends

Example usage:

import 'package:dart_ollama/dart_ollama.dart';

final repository = OllamaChatRepository(baseUrl: 'http://localhost:11434');
final stream = repository.streamChat('qwen3:0.6b', messages: [
  LLMMessage(role: LLMRole.user, content: 'Hello!')
]);

Classes

ChatGPTChatRepository
Repository for chatting with ChatGPT. Add api key and it should just work. For a reference of model names, see https://platform.openai.com/docs/models/overview
LLMChatRepository
LLMChunk
LLMMessage
LLMTool
LLMToolCall
LLMToolParam
OllamaChatRepository
Repository for chatting with Ollama. It defaults to the standard Ollama base url of http://localhost:11434.
OllamaModel
OllamaModelInfo
OllamaPullProgress
OllamaRepository
Handles communicating with Ollama letting you pull models and check if they are there
OllamaVersion

Enums

LLMRole

Exceptions / Errors

ThinkingNotAllowed
Exception thrown when trying to use thinking on a model that doesn't support it
ToolsNotAllowed
Exception thrown when trying to use tools on a model that doesn't support them
VisionNotAllowed
Exception thrown when trying to use images/vision on a model that doesn't support it