Ollama
Ollama runs open-weight models on your own machine. Supercompat points an OpenAI client at the Ollama server's OpenAI-compatible endpoint.
Install
npm install supercompat openai
Make sure Ollama itself is installed and running:
ollama serve
ollama pull llama3.2
Minimal setup
import OpenAI from 'openai'
import {
supercompat,
ollamaClientAdapter,
completionsRunAdapter,
memoryStorageAdapter,
} from 'supercompat/openai'
const ollama = new OpenAI({
apiKey: 'ollama',
baseURL: 'http://localhost:11434/v1',
})
const client = supercompat({
clientAdapter: ollamaClientAdapter({ ollama }),
storageAdapter: memoryStorageAdapter(),
runAdapter: completionsRunAdapter(),
})
const response = await client.responses.create({
model: 'llama3.2',
input: 'Say hello.',
})
Remote Ollama
Change the baseURL to reach an Ollama host on another machine:
const ollama = new OpenAI({
apiKey: 'ollama',
baseURL: 'http://gpu-box.local:11434/v1',
})
Models
Some current examples: