ollama-d 0.2.0

D bindings for the Ollama API


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ollama-d

Static Badge Latest release Artifacts

D language bindings for the Ollama AI API - Seamless integration with local AI models

Features

  • Text generation with streaming and non-streaming API
  • Chat interactions with local AI models
  • OpenAI-compatible endpoints support
  • Model management (list, create, show models)
  • Configurable timeout settings
  • Simple and intuitive API design

Prerequisites

  • Ollama server running locally (default: http://127.0.0.1:11434)
  • Installed AI model (e.g., "llama3.2")
  • Vibe.d library

Quick Examples

import ollama;
import std.stdio;

void main() {
    // Initialize Ollama client
    auto client = new OllamaClient();

    // Text generation
    auto generateResponse = client.generate("llama3.2", "Why is the sky blue?");
    writeln("Generate Response: ", generateResponse["response"].get!string);

    // Chat interaction
    Message[] messages = [Message("user", "Hello, how are you?")];
    auto chatResponse = client.chat("llama3.2", messages);
    writeln("Chat Response: ", chatResponse["message"]["content"].get!string);

    // List available models
    auto models = client.listModels();
    writeln("Available Models: ", models["models"].toString());

    // OpenAI-compatible chat completions
    auto openaiResponse = client.chatCompletions("llama3.2", messages, 50, 0.7);
    writeln("OpenAI-style Response: ", openaiResponse["choices"][0]["message"]["content"].get!string);
}

Additional Methods

  • generate(): Text generation with custom options
  • chat(): Conversational interactions
  • listModels(): Retrieve available models
  • showModel(): Get detailed model information
  • createModel(): Create custom models
  • chatCompletions(): OpenAI-compatible chat endpoint
  • completions(): OpenAI-compatible text completion

License

MIT License

Authors:
  • Matheus Catarino França
Sub packages:
ollama-d:sample
Dependencies:
vibe-d
Versions:
0.3.2 2025-Mar-22
0.3.1 2025-Mar-21
0.3.0 2025-Mar-21
0.2.0 2025-Mar-20
0.1.0 2025-Mar-19
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 7 downloads this month

  • 7 downloads total

Score:
0.8
Short URL:
ollama-d.dub.pm