GraphCanon updated today · GitHub synced today
Verify the decision
Adoption
Package downloads where a registry match exists. GitHub stars (4,310) are secondary evidence.
- npm downloads (30d)
- 2,088,357·npm downloads API·today
Maintenance and security
Full trust report- Maintenance
- Slowing (146d since push)
- As of today
- Provenance
- Not a fork · Organization account
- As of today
- Security (OSV)
- 9 low (9 low)
- As of today
Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.
Install
npm install ollama-js npmSimilar tools
Same-category neighbours. No typed graph edges are catalogued for this tool yet.
Evidence and technical details
Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.
Overview
Ollama JavaScript library
Capability facts
- MCP server
- No MCP server detected
Source: repo_scan · Jul 15, 2026
- Languages
- typescript, javascript
Source: github.language+package.json · Jul 15, 2026
Categories
Tags
README
Ollama JavaScript Library
The Ollama JavaScript library provides the easiest way to integrate your JavaScript project with Ollama.
Getting Started
npm i ollama
Usage
import ollama from 'ollama'
const response = await ollama.chat({
model: 'llama3.1',
messages: [{ role: 'user', content: 'Why is the sky blue?' }],
})
console.log(response.message.content)
Browser Usage
To use the library without node, import the browser module.
import ollama from 'ollama/browser'
Streaming responses
Response streaming can be enabled by setting stream: true, modifying function calls to return an AsyncGenerator where each part is an object in the stream.
import ollama from 'ollama'
const message = { role: 'user', content: 'Why is the sky blue?' }
const response = await ollama.chat({
model: 'llama3.1',
messages: [message],
stream: true,
})
for await (const part of response) {
process.stdout.write(part.message.content)
}
Cloud Models
Run larger models by offloading to Ollama’s cloud while keeping your local workflow.
You can see models currently available on Ollama's cloud here.
Run via local Ollama
- Sign in (one-time):
ollama signin
- Pull a cloud model:
ollama pull gpt-oss:120b-cloud
- Use as usual (offloads automatically):
import { Ollama } from 'ollama'
const ollama = new Ollama()
const response = await ollama.chat({
model: 'gpt-oss:120b-cloud',
messages: [{ role: 'user', content: 'Explain quantum computing' }],
stream: true,
})
for await (const part of response) {
process.stdout.write(part.message.content)
}
Cloud API (ollama.com)
Access cloud models directly by pointing the client at https://ollama.com.
- Create an API key, then set the
OLLAMA_API_KEYenvironment variable:
export OLLAMA_API_KEY=your_api_key
- Generate a response via the cloud API:
import { Ollama } from 'ollama'
const ollama = new Ollama({
host: 'https://ollama.com',
headers: { Authorization: 'Bearer ' + process.env.OLLAMA_API_KEY },
})
const response = await ollama.chat({
model: 'gpt-oss:120b',
messages: [{ role: 'user', content: 'Explain quantum computing' }],
stream: true,
})
for await (const part of response) {
process.stdout.write(part.message.content)
}
API
The Ollama JavaScript library's API is designed around the Ollama REST API
chat
ollama.chat(request)
-
request<Object>: The request object containing chat parameters.model<string>The name of the model to use for the chat.messages<Message[]>: Array of message objects representing the chat history.role<string>: The role of the message sender ('user', 'system', or 'assistant').content<string>: The content of the message.images<Uint8Array[] | string[]>: (Optional) Images to be included in the message, either as Uint8Array or base64 encoded strings.tool_name<string>: (Optional) Add the name of the tool that was executed to inform the model of the result
format<string>: (Optional) Set the expected format of the response (json).stream<boolean>: (Optional) When true anAsyncGeneratoris returned.think<boolean | "high" | "medium" | "low">: (Optional) Enable model thinking. Usetrue/falseor specify a level. Requires model support.logprobs<boolean>: (Optional) Return log probabilities for tokens. Requires model support.top_logprobs<number>: (Optional) Number of top log probabilities to return per token whenlogprobsis enabled.keep_alive<string | number>: (Optional) How long to keep the model loaded. A number (seconds) or a string with a duration unit suffix ("300ms
For agents
This page has a .md twin and JSON over the API.