01Why local providers
- Privacy: data stays on your infrastructure.
- Cost: no per-token API charges.
- Latency: no network round trip to a hosted API.
- Offline use: works without an internet connection once the model is installed.
- Control: choose the model, the version and where it runs.
02Ollama
The simplest way to run local models. Install Ollama, start the server and pull a model:
# Start the server
ollama serve
# Pull a model
ollama pull llama3.2import { Agent, OllamaProvider, ToolRegistry } from '@lov3kaizen/agentsea-core';
const provider = new OllamaProvider({
baseUrl: 'http://localhost:11434', // default, or set OLLAMA_BASE_URL
timeout: 60000, // default
});
const toolRegistry = new ToolRegistry();
const agent = new Agent(
{
name: 'local-assistant',
description: 'Runs locally on Ollama',
model: 'llama3.2',
provider: 'ollama',
systemPrompt: 'You are a helpful AI assistant running locally.',
temperature: 0.7,
},
provider,
toolRegistry,
);
const response = await agent.execute('What are the benefits of running AI models locally?', {
conversationId: 'local-demo',
sessionData: {},
history: [],
});
console.log(response.content);Popular models include llama3.2, llama3, mistral, gemma2, qwen2.5, codellama and phi3.
The provider also exposes listModels() and pullModel(name).
03LM Studio
A desktop app with a model browser and a built-in OpenAI-compatible server. Download a model in the app, start the local server, then point AgentSea at it.
import { Agent, LMStudioProvider, ToolRegistry } from '@lov3kaizen/agentsea-core';
const provider = new LMStudioProvider({
baseUrl: 'http://localhost:1234/v1', // default
});
const agent = new Agent(
{
name: 'lm-studio-agent',
description: 'Runs on LM Studio',
model: 'local-model', // the model you loaded in LM Studio
provider: 'openai-compatible',
systemPrompt: 'You are a helpful assistant.',
},
provider,
new ToolRegistry(),
);04LocalAI
A self-hosted, OpenAI-compatible server.
import { LocalAIProvider } from '@lov3kaizen/agentsea-core';
const provider = new LocalAIProvider({
baseUrl: 'http://localhost:8080/v1', // default
});05Text Generation WebUI
A web interface for running models, with an OpenAI-compatible API.
import { TextGenerationWebUIProvider } from '@lov3kaizen/agentsea-core';
const provider = new TextGenerationWebUIProvider({
baseUrl: 'http://localhost:5000/v1', // default
});06vLLM
An inference engine for serving models at higher request volume. Start a vLLM OpenAI-compatible server by following the vLLM documentation, then connect to it:
import { VLLMProvider } from '@lov3kaizen/agentsea-core';
const provider = new VLLMProvider({
baseUrl: 'http://localhost:8000/v1', // default
});07Other OpenAI-compatible servers
Any server that implements the OpenAI chat API can be used through OpenAICompatibleProvider. This includes Jan. baseUrl is required, and apiKey is optional.
import { OpenAICompatibleProvider } from '@lov3kaizen/agentsea-core';
const provider = new OpenAICompatibleProvider({
baseUrl: 'http://localhost:1337/v1', // your server's base URL
apiKey: process.env.LOCAL_API_KEY, // only if the server requires one
});08Provider reference
OllamaProvider({ baseUrl?, timeout? })http://localhost:11434. Reads OLLAMA_BASE_URL when no base URL is passed.LMStudioProvider({ baseUrl? })http://localhost:1234/v1.LocalAIProvider({ baseUrl? })http://localhost:8080/v1.TextGenerationWebUIProvider({ baseUrl? })http://localhost:5000/v1.VLLMProvider({ baseUrl? })http://localhost:8000/v1.OpenAICompatibleProvider({ baseUrl, apiKey? })baseUrl is required.Note
baseUrl explicitly so the target is clear in your code.09Troubleshooting
- Connection refused: check that the server is running and that the port in
baseUrlmatches it. For Ollama, runcurl http://localhost:11434. - Model not found: the
modelfield must match a model the server has loaded or pulled. - Slow responses: try a smaller or more heavily quantized model, and check that the server is using your GPU.