JavaScript SDK in Ollama
From the Ollama cheat sheet · Official SDKs · verified Jul 2026
JavaScript SDK
Install and use the official Ollama JavaScript/TypeScript library.
typescript
// Install
// npm install ollama
import ollama from 'ollama'
const response = await ollama.chat({
model: 'llama3.2',
messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.message.content)💡 The JS SDK works in Node.js and supports ESM and CommonJS imports
⚡ Streaming uses async iterators — use "for await...of" to process chunks
📌 Full TypeScript support with typed responses out of the box
🟢 Use ollama.pull() with stream: true to show download progress
javascripttypescriptsdk