
Ollama JavaScript SDK
https://github.com/ollama/ollama-js- Category
- Developer Tools
- Rank
- No. 627Tools index
Previous survey · No. 621 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- ollama
- GitHub
- 4.4k stars
- Latest release
- v0.6.3
- Date
About
Official JavaScript/TypeScript library for Ollama — run, manage, and chat with locally-served LLMs from Node or the browser.
What it does
It wraps Ollama’s HTTP endpoints in a typed client for conversations, text generation, embeddings, model administration, web search, and web fetching. Requests can return complete results or asynchronous streams. Separate runtime handling accepts browser image data and lets Node read image paths.
Why it's ranked here
The SDK covers most of the documented Ollama workflow through one consistent client, including streaming, tool use, custom headers, cloud access, and model operations. Its appeal comes from broad API coverage and direct TypeScript definitions, though several rough edges keep it from feeling fully comprehensive.
What's good
Streaming is a first-class response mode for generation, chat, model creation, pulls, and pushes. Streams are abortable and parse newline-delimited JSON across chunk boundaries. The client supports custom hosts, fetch implementations, and headers. Types cover tools, thinking levels, token probabilities, image generation fields, embeddings, and runtime options.
Tradeoffs
Creating models from local paths is explicitly unsupported, as is the documented files parameter. Aborting through one client stops every active stream on that instance, so isolated cancellation requires separate clients. Web search needs an Ollama account and API key. Experimental image generation depends on model support.
How to use it well
Choose it for TypeScript or JavaScript applications that need direct, typed control over an Ollama server or Ollama cloud. It fits chat, streamed generation, embeddings, tool loops, and model lifecycle scripts. Use one client per independently timed stream. It does not replace the Ollama server, model runtime, or account setup.
Technical notes+
package.json declares the npm package, MIT license, CommonJS and ES module entry surfaces, a browser subpath, TypeScript declarations, Vitest, ESLint, Prettier, and unbuild. src/browser.ts implements the REST client, stream tracking, browser image encoding, and endpoint dispatch. src/index.ts extends it with Node filesystem image handling and rejects local-path model creation. src/utils.ts handles host normalization, headers, cloud API-key injection, HTTP errors, newline-delimited JSON parsing, and abortable iteration. src/interfaces.ts defines request and response contracts. test/index.test.ts covers host formatting, test/utils.test.ts covers headers and split UTF-8 streaming, and test/browser.test.ts covers type exports, log probabilities, and image generation fields.
Observed
- License
- MIT
- Primary language
- TypeScript
- Install surface
- Published as the npm package ollama
- Module packaging
- CommonJS and ES module entry surfaces with TypeScript declarations
- Interface
- JavaScript and TypeScript library designed around the Ollama REST API
- Platform support
- Node and browser entry surfaces
- Tests
- Vitest tests cover host formatting, headers, stream decoding, request fields, and response fields
Read from README.md, package.json, src/index.ts, src/utils.ts, src/browser.ts, src/version.ts, src/constant.ts, src/interfaces.ts, test/index.test.ts, test/utils.test.ts, test/browser.test.ts, examples/tools/calculator.ts, examples/tools/multi-tool.ts, examples/pull-progress/pull.ts, examples/fill-in-middle/fill.ts.
What it can do
Run locally-served LLM models
Model name and configuration parameters → Running LLM instance
Chat with local LLM models
Text prompts and conversation context → AI-generated text responses
Manage local LLM models
Model management commands (install, remove, list) → Model status and metadata
Stream real-time responses from LLMs
Text prompts with streaming configuration → Streamed text tokens as they are generated
Execute LLM inference from Node.js applications
JavaScript/TypeScript code with prompts → AI-generated responses within Node.js runtime
Execute LLM inference from web browsers
JavaScript/TypeScript code with prompts in browser environment → AI-generated responses within browser runtime
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.