Building Local AI Apps and Workflows
From the course Running AI Locally: Privacy, Control & Offline Access
With local models running, you can build powerful AI applications that work entirely on your machine. Here's how to integrate local AI into real workflows.
Using the OpenAI-Compatible API
Ollama and LM Studio both expose APIs compatible with the OpenAI format. This means you can use any OpenAI SDK or library — just change the base URL:
Python:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1", # Ollama
api_key="not-needed" # Local doesn't need auth
)
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Explain RAG in one paragraph"}]
)
JavaScript/TypeScript:
const response = await fetch("http://localhost:11434/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "llama3.2",
messages: [{ role: "user", content: "Hello!" }]
})
});
Practical Local AI Applications
1. Private Document Q&A
- Index your private documents with a local embedding model
- Store vectors in a local database (SQLite + vector extension, or Chroma)
- Query with a local LLM — complete privacy, no data leaves your machine
2. Code Assistant
- Run CodeLlama or DeepSeek Coder locally
- Connect to VS Code with the Continue extension
- Get AI code completion and chat without sending code to the cloud
3. Email/Writing Assistant
- Use Ollama as a backend for a local writing tool
- Draft, rewrite, summarize, and translate — all offline
- Perfect for sensitive communications
4. Data Analysis Pipeline
- Process CSV/JSON files through a local model
- Extract entities, classify records, summarize reports
- Handle sensitive data (financial, medical, legal) safely
5. Local Chatbot for Your Knowledge Base Combine Ollama + Chroma + a simple web interface:
- Ingest your documents into Chroma with local embeddings
- Build a simple chat UI (Streamlit, Gradio, or web app)
- On each query: retrieve relevant chunks → prompt local LLM → display answer
Connecting Local AI to Existing Tools
Open WebUI — Self-hosted ChatGPT-like interface for Ollama
- Beautiful chat UI with conversation history
- Multi-model support and model switching
- RAG built-in (upload documents directly)
- User management for team use
- Docker:
docker run -p 3000:8080 ghcr.io/open-webui/open-webui
Continue (VS Code Extension) — AI code assistant powered by local models
- Tab autocomplete with local models
- Chat panel in VS Code
- Supports Ollama, LM Studio, and llama.cpp backends
AnythingLLM — All-in-one local AI workspace
- Document ingestion and RAG
- Multiple LLM backend support
- Agent capabilities with tool use
- Desktop app or Docker deployment
Performance Tips
- Keep models loaded — First query is slow (model loading). Subsequent queries are fast.
- Use the right model size — Don't run 70B when 7B does the job. Smaller = faster.
- Batch processing — For large datasets, process in batches and save results
- Monitor resources — Watch VRAM usage, CPU temp, and disk I/O
- Context length — Shorter contexts = faster generation. Don't pad unnecessarily.
The Local AI Stack
A complete local AI development environment:
- Ollama — Model management and inference
- Open WebUI — Chat interface
- Chroma — Vector database for RAG
- Continue — Code assistant in VS Code
- Python + OpenAI SDK — Custom applications
All free, all open source, all running on your hardware.
Key Takeaways
- •Local models expose OpenAI-compatible APIs — use any existing SDK or library
- •Build private document Q&A, code assistants, and data pipelines with zero cloud dependency
- •Open WebUI provides a ChatGPT-like interface for local models with built-in RAG
- •Continue extension brings local AI code assistance directly into VS Code
- •The full local AI stack (Ollama + Open WebUI + Chroma + Continue) is free and open source
Progress is kept in this browser only.