npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ollama-bridge

v0.1.7

Published

High-performance Node.js bindings for Ollama integration

Readme

ollama-bridge

High-performance Node.js bindings for Ollama integration.

npm version

Installation

From NPM

npm install ollama-bridge

From Source (Development)

# Clone and build Rust library first
git clone https://github.com/aumbriac/ollama-bridge.git
cd ollama-bridge
cargo build --release

# Install Node.js bindings
cd bindings/node
npm install
npm run build

Quick Start

Automatic Setup (Recommended)

import { OllamaClient, ChatMessage } from 'ollama-bridge';

async function main() {
    // Create client with auto-install enabled
    // This will automatically install and start Ollama if needed!
    const client = new OllamaClient({
        autoInstall: true,
        autoStart: true
    });
    
    // Chat example - Ollama will be set up automatically
    const messages = [
        ChatMessage.system('You are a helpful assistant.'),
        ChatMessage.user('What is the capital of France?')
    ];
    
    const response = await client.chat('llama3:latest', messages);
    console.log(response.content);
}

main();

Manual Setup

import { OllamaClient, ChatMessage } from 'ollama-bridge';

async function main() {
    const client = new OllamaClient();
    
    // Check if Ollama is running
    if (!client.healthCheck()) {
        console.log('Please start Ollama: ollama serve');
        return;
    }
    
    const response = await client.chat('llama3:latest', messages);
    console.log(response.content);
}

main();

API Reference

OllamaClient

interface OllamaConfig {
    baseUrl?: string;      // Default: http://localhost:11434
    autoStart?: boolean;   // Auto-start Ollama if not running (default: true)
    autoInstall?: boolean; // Auto-install Ollama if not found (default: false)
}

class OllamaClient {
    // New config-based constructor (recommended)
    constructor(config?: OllamaConfig)
    
    // Backward-compatible constructors
    constructor(baseUrl?: string)
    constructor()
    
    // Chat with a model
    chat(model: string, messages: ChatMessage[]): Promise<ChatResponse>
    
    // Generate text
    generate(model: string, prompt: string): Promise<GenerateResponse>
    
    // Check if Ollama is running
    healthCheck(): boolean
}

Configuration Examples

// Automatic setup - installs and starts Ollama if needed
const client = new OllamaClient({
    autoInstall: true,
    autoStart: true
});

// Custom URL with auto-start only
const client = new OllamaClient({
    baseUrl: 'http://remote-ollama:11434',
    autoStart: true,
    autoInstall: false
});

// Manual setup - no automation
const client = new OllamaClient({
    autoStart: false,
    autoInstall: false
});

// Backward compatible - same as default
const client = new OllamaClient();
const client = new OllamaClient('http://localhost:11434');

ChatMessage Helpers

// Create messages easily
ChatMessage.user('Hello!')                     // User message
ChatMessage.system('You are helpful.')         // System message
ChatMessage.assistant('How can I help?')       // Assistant message

// With images
ChatMessage.user('What is this?', ['base64_image'])

Types

interface ChatMessage {
    role: 'user' | 'assistant' | 'system';
    content: string;
    images?: string[];
}

interface ChatResponse {
    content: string;
}

interface GenerateResponse {
    response: string;
}

Examples

See the examples/node directory for complete examples.

Local Development

Using in Another Project

# Method 1: npm link (best for development)
cd bindings/node
npm link
cd /your/project
npm link ollama-bridge

# Method 2: Direct install
cd /your/project
npm install /path/to/ollama-bridge/bindings/node

# Method 3: Pack and install
cd bindings/node
npm pack  # Creates ollama-bridge-0.1.0.tgz
cd /your/project
npm install /path/to/ollama-bridge-0.1.0.tgz

Building

npm run build  # Build everything
tsc           # Just TypeScript
node-gyp rebuild  # Just native module

Testing

npm test

License

MIT OR Apache-2.0