DEV Community

Gather
Gather

Posted on

How I Built a Zero-API-Cost AI Agent That Runs 100% Locally — No Keys, No Cloud, No Bills

I got tired of paying $50/month for API tokens and sending my data to servers I don't control.

So I built LocalMind — a lightweight AI agent framework that runs entirely on your own machine
via Ollama or WebGPU. No API keys. No telemetry. No recurring cost. Ever.

The agent uses a full ReAct loop (Reason → Act → Observe) with tool calling, streaming output,
conversation memory, and JSON Schema validation — all in vanilla ESM JavaScript with zero
runtime dependencies.

What it can do:

  • Connect to any local Ollama model (Llama 3.2, Mistral, Gemma, DeepSeek...)
  • Run inference directly in the browser via WebGPU/WebLLM — no server needed
  • Call custom tools you define with full input validation
  • Stream tokens in real time
  • Maintain conversation memory with snapshot/restore
  • Emit granular events for every step of the agent loop

Quick start:

npm install localmind

import { Agent, OllamaAdapter, calculatorTool, dateTimeTool } from 'localmind';

const agent = new Agent({
adapter: new OllamaAdapter({ model: 'llama3.2' }),
tools: [calculatorTool, dateTimeTool],
});

const result = await agent.run('What is 1234 * 5678 and what day is today?');
console.log(result);

Your data never leaves your machine. That's the whole point.

GitHub: https://github.com/andrexdd/localmind

Top comments (0)