Skip to content

Ollama

The Ollama plugin enables local AI capabilities using Ollama, with no cloud API required.

Terminal window
pnpm add @teamflojo/floimg-ollama

Install and run Ollama locally:

Terminal window
# Install Ollama (macOS)
brew install ollama
# Pull required models
ollama pull llava # For vision
ollama pull llama3.2 # For text
# Start the Ollama server
ollama serve
import createClient from '@teamflojo/floimg';
import ollama from '@teamflojo/floimg-ollama';
const floimg = createClient();
floimg.registerGenerator(ollama({
baseUrl: 'http://localhost:11434' // Default Ollama URL
}));

Analyze images using LLaVA locally.

const analysis = await floimg.analyzeImage({
blob: image,
prompt: 'Describe this image in detail'
});
console.log(analysis.text);
// "The image shows a cozy living room with..."
ParameterTypeRequiredDescription
modelstringNoVision model (default: llava)
promptstringYesQuestion or instruction about the image

Generate text using Llama locally.

const result = await floimg.generateText({
prompt: 'Write a caption for a beach sunset photo',
model: 'llama3.2'
});
console.log(result.text);
// "Golden hour magic at the beach..."
ParameterTypeRequiredDescription
modelstringNoText model (default: llama3.2)
promptstringYesThe prompt for text generation
ModelTypeSizeUse Case
llavaVision7BImage analysis, description
llava:13bVision13BHigher quality analysis
llama3.2Text3BFast text generation
llama3.2:7bText7BBetter quality text

Pull additional models with:

Terminal window
ollama pull llava:13b
ollama pull llama3.2:7b
import createClient from '@teamflojo/floimg';
import ollama from '@teamflojo/floimg-ollama';
import qr from '@teamflojo/floimg-qr';
const floimg = createClient();
floimg.registerGenerator(ollama());
floimg.registerGenerator(qr());
// 1. Analyze an image locally
const analysis = await floimg.analyzeImage({
blob: productImage,
prompt: 'Describe this product for an e-commerce listing'
});
// 2. Generate a caption
const caption = await floimg.generateText({
prompt: `Write a short marketing tagline based on: ${analysis.text}`
});
// 3. Create a QR code linking to the product
const qrCode = await floimg.generate({
generator: 'qr',
params: { data: 'https://example.com/product/123' }
});
console.log(caption.text);
  • Privacy: All processing happens locally
  • No API Costs: No per-request charges
  • Offline: Works without internet connection
  • Fast: No network latency for local inference