Repolode
ollama

ollama/ollama-js

The official JavaScript/TypeScript client library for Ollama, for chatting with and managing local or cloud LLMs from Node.js and browsers.

Stars
4,397
Forks
482
Open issues
99
Last commit
6 days ago

What is it?

ollama-js is the official JavaScript client for Ollama, a runtime for running large language models. It wraps the Ollama REST API in a promise-based interface, so Node.js and browser applications can send chat and generate requests, pull or push models, create custom models, and list or inspect what is installed.

The library installs from npm as `ollama`, with a separate `ollama/browser` entry point for use outside Node. Responses can be streamed through an async generator, and a custom client can set the host, fetch implementation, and headers. The library also covers embeddings, tool calling, image inputs, and an abort method for cancelling active streams.

It also supports cloud models: by signing in to a local Ollama instance or pointing the client at ollama.com with an API key, the same calls can run larger hosted models. Web search and web fetch helpers, along with a System One decision API, are included as well.

Key features

  • 01Chat and generate requests with optional streaming via async generators.
  • 02Model management methods: pull, push, create, copy, delete, list, and show.
  • 03Embedding generation and tool calling support.
  • 04Separate browser entry point at `ollama/browser`.
  • 05Custom client options for host, fetch, and request headers.
  • 06Cloud model access through ollama.com with an API key.

Use cases

  • Adding a local LLM chat feature to a Node.js backend or script.
  • Building a browser-based chat interface that talks to a local Ollama server.
  • Generating embeddings for search or retrieval pipelines from JavaScript code.
  • Calling larger hosted models from the same code used for local ones.

Quick start

  1. 1

    Install the library with npm

    npm i ollama
  2. 2

    Import the client and call chat with a model

Things to know

  • Requires a running Ollama server or an Ollama account API key for cloud models.
  • Cloud features such as web search and cloud models need an Ollama account.

Topics

FAQ

What is ollama-js?
The official JavaScript/TypeScript client library for Ollama, for chatting with and managing local or cloud LLMs from Node.js and browsers. ollama-js is the official JavaScript client for Ollama, a runtime for running large language models. It wraps the Ollama REST API in a promise-based interface, so Node.js and browser applications can send chat and generate requests, pull or push models, create custom models, and list or inspect what is installed.
Is ollama-js free to use? What license does it have?
ollama-js is open source under the MIT license. Check the license terms before using it in commercial products.
Is ollama-js still maintained?
Actively maintained. The last commit to ollama-js was on Oct 16, 2026.
What can I use ollama-js for?
Adding a local LLM chat feature to a Node.js backend or script. Building a browser-based chat interface that talks to a local Ollama server. Generating embeddings for search or retrieval pipelines from JavaScript code. Calling larger hosted models from the same code used for local ones.
How do I install ollama-js?
Install the library with npm: npm i ollama Import the client and call chat with a model
Where can I get ollama-js?
The source code and installation instructions are on GitHub: https://github.com/ollama/ollama-js

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects